[SCM] UID Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Dec 4 09:09:14 MST 2013


The branch, master has been updated
       via  6d5eb67 tests: Use SYS_gettimeofday for testing.
      from  37076a7 tests: Fix testsuite on Solaris.

http://gitweb.samba.org/?p=uid_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6d5eb67f67ce37e409aa26721d70b0400c7b2cee
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Wed Dec 4 17:08:19 2013 +0100

    tests: Use SYS_gettimeofday for testing.
    
    SYS_stat is a bad idea cause you need to know kernel internals.

-----------------------------------------------------------------------

Summary of changes:
 tests/testsuite.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index a666067..ddf3ee4 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -11,6 +11,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <unistd.h>
 
 #ifdef HAVE_SYS_SYSCALL_H
@@ -20,6 +21,8 @@
 #include <syscall.h>
 #endif
 
+#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+
 static void test_uwrap_seteuid(void **state)
 {
 	int rc;
@@ -109,7 +112,8 @@ static void test_uwrap_syscall(void **state)
 {
 	long int rc;
 	char *env;
-	struct stat sb;
+	struct timeval tv1, tv2;
+	struct timezone tz1, tz2;
 
 	env = getenv("UID_WRAPPER");
 	if (env == NULL) {
@@ -119,16 +123,29 @@ static void test_uwrap_syscall(void **state)
 
 	(void) state; /* unused */
 
+	rc = syscall(SYS_getpid);
+	assert_int_equal(rc, getpid());
+
 	rc = access(".", R_OK);
 	assert_int_equal(rc, 0);
 
 	rc = syscall(SYS_access, ".", R_OK);
 	assert_int_equal(rc, 0);
 
-	rc = syscall(SYS_stat, ".", &sb);
+	ZERO_STRUCT(tv1);
+	ZERO_STRUCT(tv2);
+	ZERO_STRUCT(tz1);
+	ZERO_STRUCT(tz2);
+
+	rc = gettimeofday(&tv1, &tz1);
+	assert_int_equal(rc, 0);
+
+	rc = syscall(SYS_gettimeofday, &tv2, &tz2);
 	assert_int_equal(rc, 0);
 
-	assert_true(S_ISDIR(sb.st_mode));
+	assert_int_equal(tv1.tv_sec, tv2.tv_sec);
+	assert_int_equal(tz2.tz_dsttime, tz2.tz_dsttime);
+	assert_int_equal(tz2.tz_minuteswest, tz2.tz_minuteswest);
 }
 
 static void test_uwrap_syscall_setreuid(void **state)


-- 
UID Wrapper Repository


More information about the samba-cvs mailing list