summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/test-tables.h8
-rw-r--r--src/test/test-tables.c3
2 files changed, 8 insertions, 3 deletions
diff --git a/src/shared/test-tables.h b/src/shared/test-tables.h
index ac7deda39b..deebec2ed2 100644
--- a/src/shared/test-tables.h
+++ b/src/shared/test-tables.h
@@ -29,15 +29,17 @@ static inline void _test_table(const char *name,
int size) {
int i;
- for (i = 0; i < size; i++) {
+ for (i = 0; i < size + 1; i++) {
const char* val = lookup(i);
- int rev = -1;
+ int rev;
if (val)
rev = reverse(val);
+ else
+ rev = reverse("--no-such--value----");
printf("%s: %d → %s → %d\n", name, i, val, rev);
- if (!val || rev != i)
+ if (i < size ? val == NULL || rev != i : val != NULL || rev != -1)
exit(EXIT_FAILURE);
}
}
diff --git a/src/test/test-tables.c b/src/test/test-tables.c
index dff6431b6d..9a3d3e8e74 100644
--- a/src/test/test-tables.c
+++ b/src/test/test-tables.c
@@ -43,6 +43,7 @@
#include "unit-name.h"
#include "unit.h"
#include "util.h"
+#include "syscall-list.h"
#include "test-tables.h"
@@ -98,5 +99,7 @@ int main(int argc, char **argv) {
test_table(unit_load_state, UNIT_LOAD_STATE);
test_table(unit_type, UNIT_TYPE);
+ _test_table("syscall", syscall_to_name, syscall_from_name, syscall_max());
+
return EXIT_SUCCESS;
}