Skip to content

Commit bf33139

Browse files
committed
librlist/test: test simple invalid resource config entries
Problem: There are no unit tests for rlist_from_config(). Save the more complex tests for a sharness test, but test some of the simpler invalid configuration scenarios in the rlist unit tests.
1 parent 5778815 commit bf33139

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/common/librlist/test/rlist.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,36 @@ static void test_issue4290 (void)
19471947
free (R);
19481948
}
19491949

1950+
static void test_rlist_config_inval (void)
1951+
{
1952+
flux_error_t error;
1953+
json_t *o;
1954+
1955+
ok (rlist_from_config (NULL, &error) == NULL,
1956+
"rlist_from_config (NULL) fails");
1957+
is (error.text, "resource config must be an array",
1958+
"error.text is expected: %s",
1959+
error.text);
1960+
1961+
if (!(o = json_object()))
1962+
BAIL_OUT ("test_rlist_config_inval: json_object: %s", strerror (errno));
1963+
ok (rlist_from_config (o, &error) == NULL,
1964+
"rlist_from_config() with empty object fails");
1965+
is (error.text, "resource config must be an array",
1966+
"error.text is expected: %s",
1967+
error.text);
1968+
json_decref (o);
1969+
1970+
if (!(o = json_array ()))
1971+
BAIL_OUT ("test_rlist_config_inval: json_array: %s", strerror (errno));
1972+
ok (rlist_from_config (o, &error) == NULL,
1973+
"rlist_from_config() with empty array fails");
1974+
is (error.text, "no hosts configured",
1975+
"error.text is expected: %s",
1976+
error.text);
1977+
json_decref (o);
1978+
}
1979+
19501980
int main (int ac, char *av[])
19511981
{
19521982
plan (NO_PLAN);
@@ -1975,6 +2005,7 @@ int main (int ac, char *av[])
19752005
test_issue4184 ();
19762006
test_properties ();
19772007
test_issue4290 ();
2008+
test_rlist_config_inval ();
19782009

19792010
done_testing ();
19802011
}

0 commit comments

Comments
 (0)