]> git.saurik.com Git - apple/xnu.git/blobdiff - tests/settimeofday_29193041_entitled.c
xnu-4903.270.47.tar.gz
[apple/xnu.git] / tests / settimeofday_29193041_entitled.c
index 51ca5a5ed77a0a93d08a3814607f32f8bc81a7b6..38bc47ad05785cb5d5cc5f344269b1f7aba4cb1e 100644 (file)
 #define DAY 86400 //1 day in sec
 
 T_DECL(settime_32089962_entitled_root,
 #define DAY 86400 //1 day in sec
 
 T_DECL(settime_32089962_entitled_root,
-       "Verify that root privileges can allow to change the time",
-       T_META_ASROOT(true), T_META_CHECK_LEAKS(false))
+    "Verify that root privileges can allow to change the time",
+    T_META_ASROOT(true), T_META_CHECK_LEAKS(false))
 {
        struct timeval settimeofdaytime;
        struct timeval adj_time;
        struct timex ntptime;
 
 {
        struct timeval settimeofdaytime;
        struct timeval adj_time;
        struct timex ntptime;
 
-       if (geteuid() != 0){
-                T_SKIP("settime_32089962_entitled_root test requires root privileges to run.");
-        }
+       if (geteuid() != 0) {
+               T_SKIP("settime_32089962_entitled_root test requires root privileges to run.");
+       }
 
        /* test settimeofday */
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&settimeofdaytime, NULL), NULL);
 
        /* test settimeofday */
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&settimeofdaytime, NULL), NULL);
@@ -41,7 +41,7 @@ T_DECL(settime_32089962_entitled_root,
        /* test adjtime */
        adj_time.tv_sec = 1;
        adj_time.tv_usec = 0;
        /* test adjtime */
        adj_time.tv_sec = 1;
        adj_time.tv_usec = 0;
-       T_ASSERT_POSIX_ZERO(adjtime(&adj_time, NULL),NULL);
+       T_ASSERT_POSIX_ZERO(adjtime(&adj_time, NULL), NULL);
 
        /* test ntp_adjtime */
        memset(&ntptime, 0, sizeof(ntptime));
 
        /* test ntp_adjtime */
        memset(&ntptime, 0, sizeof(ntptime));
@@ -52,17 +52,16 @@ T_DECL(settime_32089962_entitled_root,
 }
 
 T_DECL(settime_32089962_entitled_not_root,
 }
 
 T_DECL(settime_32089962_entitled_not_root,
-       "Verify that the \"com.apple.settime\" entitlement can allow to change the time",
-       T_META_ASROOT(false), T_META_CHECK_LEAKS(false))
+    "Verify that the \"com.apple.settime\" entitlement can allow to change the time",
+    T_META_ASROOT(false), T_META_CHECK_LEAKS(false))
 {
 {
-
        struct timeval settimeofdaytime;
        struct timeval adj_time;
        struct timex ntptime;
 
        struct timeval settimeofdaytime;
        struct timeval adj_time;
        struct timex ntptime;
 
-       if (geteuid() == 0){
-                T_SKIP("settime_32089962_entitled_root test requires no root privileges to run.");
-        }
+       if (geteuid() == 0) {
+               T_SKIP("settime_32089962_entitled_root test requires no root privileges to run.");
+       }
 
        /* test settimeofday */
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&settimeofdaytime, NULL), NULL);
 
        /* test settimeofday */
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&settimeofdaytime, NULL), NULL);
@@ -71,7 +70,7 @@ T_DECL(settime_32089962_entitled_not_root,
        /* test adjtime */
        adj_time.tv_sec = 1;
        adj_time.tv_usec = 0;
        /* test adjtime */
        adj_time.tv_sec = 1;
        adj_time.tv_usec = 0;
-       T_ASSERT_POSIX_ZERO(adjtime(&adj_time, NULL),NULL);
+       T_ASSERT_POSIX_ZERO(adjtime(&adj_time, NULL), NULL);
 
        /* test ntp_adjtime */
        memset(&ntptime, 0, sizeof(ntptime));
 
        /* test ntp_adjtime */
        memset(&ntptime, 0, sizeof(ntptime));
@@ -79,19 +78,18 @@ T_DECL(settime_32089962_entitled_not_root,
        ntptime.status = TIME_OK;
 
        T_ASSERT_EQ(ntp_adjtime(&ntptime), TIME_OK, NULL);
        ntptime.status = TIME_OK;
 
        T_ASSERT_EQ(ntp_adjtime(&ntptime), TIME_OK, NULL);
-
 }
 
 T_DECL(settimeofday_29193041_entitled_root,
 }
 
 T_DECL(settimeofday_29193041_entitled_root,
-       "Verify that root privileges can allow to change the time",
-       T_META_ASROOT(true), T_META_CHECK_LEAKS(false))
+    "Verify that root privileges can allow to change the time",
+    T_META_ASROOT(true), T_META_CHECK_LEAKS(false))
 {
        struct timeval time;
        long new_time;
 
 {
        struct timeval time;
        long new_time;
 
-       if (geteuid() != 0){
-                T_SKIP("settimeofday_root_29193041 test requires root privileges to run.");
-        }
+       if (geteuid() != 0) {
+               T_SKIP("settimeofday_root_29193041 test requires root privileges to run.");
+       }
 
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&time, NULL), NULL);
 
 
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&time, NULL), NULL);
 
@@ -109,19 +107,19 @@ T_DECL(settimeofday_29193041_entitled_root,
        T_EXPECT_GE_LONG(time.tv_sec, new_time, "Time changed with root and entitlement");
 
        time.tv_sec -= DAY;
        T_EXPECT_GE_LONG(time.tv_sec, new_time, "Time changed with root and entitlement");
 
        time.tv_sec -= DAY;
-       T_QUIET;T_ASSERT_POSIX_ZERO(settimeofday(&time, NULL), NULL);
+       T_QUIET; T_ASSERT_POSIX_ZERO(settimeofday(&time, NULL), NULL);
 }
 
 T_DECL(settimeofday_29193041_entitled_not_root,
 }
 
 T_DECL(settimeofday_29193041_entitled_not_root,
-       "Verify that the \"com.apple.settime\" entitlement can allow to change the time",
-       T_META_ASROOT(false), T_META_CHECK_LEAKS(false))
+    "Verify that the \"com.apple.settime\" entitlement can allow to change the time",
+    T_META_ASROOT(false), T_META_CHECK_LEAKS(false))
 {
        struct timeval time;
        long new_time;
 
 {
        struct timeval time;
        long new_time;
 
-       if (geteuid() == 0){
-                T_SKIP("settimeofday_29193041 test requires no root privileges to run.");
-        }
+       if (geteuid() == 0) {
+               T_SKIP("settimeofday_29193041 test requires no root privileges to run.");
+       }
 
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&time, NULL), NULL);
 
 
        T_QUIET; T_ASSERT_POSIX_ZERO(gettimeofday(&time, NULL), NULL);
 
@@ -137,7 +135,7 @@ T_DECL(settimeofday_29193041_entitled_not_root,
 
        /* expext to be past new_time */
        T_EXPECT_GE_LONG(time.tv_sec, new_time, "Time successfully changed without root and with entitlement");
 
        /* expext to be past new_time */
        T_EXPECT_GE_LONG(time.tv_sec, new_time, "Time successfully changed without root and with entitlement");
-       
+
        time.tv_sec -= DAY;
        T_QUIET; T_ASSERT_POSIX_ZERO(settimeofday(&time, NULL), NULL);
 }
        time.tv_sec -= DAY;
        T_QUIET; T_ASSERT_POSIX_ZERO(settimeofday(&time, NULL), NULL);
 }