tests: Add test_uwrap_syscall_setregid().
authorAndreas Schneider <asn@cryptomilk.org>
Thu, 6 Jun 2013 08:14:06 +0000 (10:14 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 6 Jun 2013 08:14:06 +0000 (10:14 +0200)
tests/testsuite.c

index 0b8686916b9fd414ca41b6ccb35c0f5df700dc78..aeb729f8695a51ea253cb0852d91feeef7ebc886 100644 (file)
@@ -71,7 +71,7 @@ static void test_uwrap_setegid(void **state)
        assert_int_equal(u, 42);
 }
 
-static void test_uwrap_syscall(void **state)
+static void test_uwrap_syscall_setreuid(void **state)
 {
        long int rc;
        uid_t u;
@@ -98,13 +98,41 @@ static void test_uwrap_syscall(void **state)
        assert_int_equal(u, 42);
 }
 
+static void test_uwrap_syscall_setregid(void **state)
+{
+       long int rc;
+       uid_t u;
+       char *env;
+
+       env = getenv("UID_WRAPPER");
+       if (env == NULL) {
+               printf("UID_WRAPPER env not set, uid_wrapper is disabled\n");
+               return;
+       }
+
+       (void) state; /* unused */
+
+       rc = syscall(SYS_setregid, -1, 0);
+       assert_int_equal(rc, 0);
+
+       u = getegid();
+       assert_int_equal(u, 0);
+
+       rc = syscall(SYS_setregid, -1, 42);
+       assert_int_equal(rc, 0);
+
+       u = getegid();
+       assert_int_equal(u, 42);
+}
+
 int main(void) {
        int rc;
 
        const UnitTest tests[] = {
                unit_test(test_uwrap_seteuid),
                unit_test(test_uwrap_setegid),
-               unit_test(test_uwrap_syscall),
+               unit_test(test_uwrap_syscall_setreuid),
+               unit_test(test_uwrap_syscall_setregid),
        };
 
        rc = run_tests(tests);