Adapt tests for a new libsmack API
authorJan Cybulski <j.cybulski@samsung.com>
Thu, 25 Jul 2013 09:42:58 +0000 (11:42 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 14:07:37 +0000 (15:07 +0100)
    [Issue#]   SSDWSSP-433
    [Bug]      N/A
    [Cause]    Changed API of libsmack.
    [Problem]  Function smack_new_label_from_socket() is now returning value greater than 0 on success, not 0 as it was before.
    [Solution] Changes of expected function results
    [Verification] Run tests.

Change-Id: I713319cddd53306be609e4dc33fdf7c2b74f457a

tests/libprivilege-control-tests/test_cases.cpp
tests/libsmack-tests/test_cases.cpp
tests/security-server-tests/security_server_tests_label.cpp

index d064bb1..eedd427 100644 (file)
@@ -1170,7 +1170,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -1208,7 +1208,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege_wgt)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(WGT_APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -1237,7 +1237,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege_wgt_partner)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(WGT_PARTNER_APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -1265,7 +1265,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege_wgt_platform)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(WGT_PLATFORM_APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -1293,7 +1293,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege_osp)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(OSP_APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -1321,7 +1321,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege_osp_partner)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(OSP_PARTNER_APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -1349,7 +1349,7 @@ RUNNER_CHILD_TEST_SMACK(privilege_control05_set_app_privilege_osp_platform)
     // Check if SMACK label really set
     char *label;
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error getting current process label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error getting current process label");
     RUNNER_ASSERT_MSG(label != NULL, "Process label is not set");
     result = strcmp(OSP_PLATFORM_APP_ID, label);
     RUNNER_ASSERT_MSG(result == 0, "Process label " << label << " is incorrect");
@@ -2178,7 +2178,7 @@ static void smack_unix_sock_server(int sock)
     if (fd < 0)
         return;
     result = smack_new_label_from_self(&smack_label);
-    if (result != 0) {
+    if (result < 0) {
         close(fd);
         close(sock);
         free(smack_label);
index ad38305..326c417 100644 (file)
@@ -733,7 +733,7 @@ RUNNER_TEST_SMACK(smack05_self_label)
 
     //int smack_new_label_from_self(char **label);
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error in getting self label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error in getting self label");
 
     //comparing this label with default one "_"
     result = strcmp(label, def_rule);
@@ -757,7 +757,7 @@ RUNNER_TEST_SMACK(smack05_self_label)
 
     //checking new label using smack function
     result = smack_new_label_from_self(&label);
-    RUNNER_ASSERT_MSG(result == 0, "Error in getting self label");
+    RUNNER_ASSERT_MSG(result >= 0, "Error in getting self label");
     result = strcmp(label, "cola");
     RUNNER_ASSERT_MSG(result == 0, "Wrong process label");
 
@@ -1389,7 +1389,7 @@ static void smack_unix_sock_server(int sock)
     if (fd < 0)
         return;
     result = smack_new_label_from_self(&smack_label);
-    RUNNER_ASSERT_MSG(result == 0, "smack_new_label_from_self() failed");
+    RUNNER_ASSERT_MSG(result >= 0, "smack_new_label_from_self() failed");
     result = write(fd, smack_label, strlen(smack_label));
     RUNNER_ASSERT_MSG(result == (int)strlen(smack_label), "write() failed");
     close(fd);
@@ -1446,7 +1446,7 @@ RUNNER_TEST_SMACK(smack09_new_label_from_socket)
             alarm(0);
             smack_label1[result] = '\0';
             result = smack_new_label_from_socket(sock, &smack_label2);
-            RUNNER_ASSERT_MSG(result == 0, "smack_label_from_socket failed");
+            RUNNER_ASSERT_MSG(result >= 0, "smack_label_from_socket failed");
             result = strcmp(smack_label1, smack_label2);
             if (i < 3)
                 RUNNER_ASSERT_MSG(result == 0, "smack labels differ: '" << smack_label1 << "' != '" << smack_label2 << "' i == " << i);
index 83b15df..64a810e 100644 (file)
@@ -42,7 +42,7 @@ RUNNER_TEST_SMACK(tc_security_server_get_smacklabel_cookie) {
     SLOGD("%s %d", "This binary PID is:", mypid);
 
     res = smack_new_label_from_self(&label_smack);
-    if (0 != res) {
+    if (res < 0) {
         if (NULL != label_smack)
             free(label_smack);
         if (NULL != label_ss)