diff options
author | Paul Moore <paul@paul-moore.com> | 2019-11-04 20:21:41 -0500 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2019-11-13 20:33:05 -0500 |
commit | b233c4048bf85e5055e6becf2dd23efbf5436a99 (patch) | |
tree | b3b2391142f7d9e53cba27ba07cdab936170a7f4 /tests | |
parent | e3647f5b6b52996bf30d0c2c1d1248e4182e1c1c (diff) | |
download | libseccomp-b233c4048bf85e5055e6becf2dd23efbf5436a99.tar.gz |
tests: add some additional test code to boost our code coverage
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/16-sim-arch_basic.c | 6 | ||||
-rw-r--r-- | tests/39-basic-api_level.c | 20 | ||||
-rwxr-xr-x | tests/39-basic-api_level.py | 12 |
3 files changed, 34 insertions, 4 deletions
diff --git a/tests/16-sim-arch_basic.c b/tests/16-sim-arch_basic.c index 7495f82..5413e18 100644 --- a/tests/16-sim-arch_basic.c +++ b/tests/16-sim-arch_basic.c @@ -51,6 +51,12 @@ int main(int argc, char *argv[]) if (rc != 0) goto out; + /* NOTE: we are using a different approach to test for the native arch + * to exercise slightly different code paths */ + rc = seccomp_arch_exist(ctx, 0); + if (rc != -EEXIST) + goto out; + /* NOTE: more sanity/coverage tests (see above) */ rc = seccomp_arch_add(ctx, SCMP_ARCH_NATIVE); if (rc != 0) diff --git a/tests/39-basic-api_level.c b/tests/39-basic-api_level.c index 9ce3b41..72801b5 100644 --- a/tests/39-basic-api_level.c +++ b/tests/39-basic-api_level.c @@ -54,14 +54,28 @@ int main(int argc, char *argv[]) if (api != 3) return -7; + rc = seccomp_api_set(4); + if (rc != 0) + return -8; + api = seccomp_api_get(); + if (api != 4) + return -9; + + rc = seccomp_api_set(5); + if (rc != 0) + return -10; + api = seccomp_api_get(); + if (api != 5) + return -11; + /* Attempt to set a high, invalid API level */ rc = seccomp_api_set(1024); if (rc != -EINVAL) - return -8; + return -1001; /* Ensure that the previously set API level didn't change */ api = seccomp_api_get(); - if (api != 3) - return -9; + if (api != 5) + return -1002; return 0; } diff --git a/tests/39-basic-api_level.py b/tests/39-basic-api_level.py index 9c40c33..755ca02 100755 --- a/tests/39-basic-api_level.py +++ b/tests/39-basic-api_level.py @@ -50,6 +50,16 @@ def test(): if api != 3: raise RuntimeError("Failed getting API level 3") + set_api(4) + api = get_api() + if api != 4: + raise RuntimeError("Failed getting API level 4") + + set_api(5) + api = get_api() + if api != 5: + raise RuntimeError("Failed getting API level 5") + # Attempt to set a high, invalid API level try: set_api(1024) @@ -59,7 +69,7 @@ def test(): raise RuntimeError("Missing failure when setting invalid API level") # Ensure that the previously set API level didn't change api = get_api() - if api != 3: + if api != 5: raise RuntimeError("Failed getting old API level after setting an invalid API level") test() |