tests/logsv/logtest.c      |  20 +++++++++
 tests/logsv/logtest.h      |   3 +
 tests/logsv/tet_LogOiOps.c |  97 ++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 105 insertions(+), 15 deletions(-)


saLogOi_48:
Change back to original root path and remove xxtest dir after test
Change mode/permission for xxtest so that it can be used also if
server and payload running test have different permissions

saLogOi_73:
Removed osafassert and give better error reporting

diff --git a/tests/logsv/logtest.c b/tests/logsv/logtest.c
--- a/tests/logsv/logtest.c
+++ b/tests/logsv/logtest.c
@@ -16,8 +16,10 @@
  */
 
 #include <sys/time.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #include <limits.h>
+#include <stdlib.h>
 #include <configmake.h>
 #include <saImmOm.h>
 #include <immutil.h>
@@ -129,6 +131,24 @@ SaLogCallbacksT logCallbacks = {NULL, NU
 SaSelectionObjectT selectionObject;
 char log_root_path[PATH_MAX];
 
+/**
+ * Same as system() but returns WEXITSTATUS
+ * 
+ * @param command[in] Same as system()
+ * @return -1 on system error else return WEXITSTATUS return code
+ *
+ */
+int tet_system(const char *command) {
+       
+       rc = system(command);
+       if (rc == -1) {
+               fprintf(stderr, "system() retuned -1 Fail");
+       } else {
+               rc = WEXITSTATUS(rc);
+       }
+       return rc;
+}
+
 void init_logrootpath(void)
 {
        SaImmHandleT omHandle;
diff --git a/tests/logsv/logtest.h b/tests/logsv/logtest.h
--- a/tests/logsv/logtest.h
+++ b/tests/logsv/logtest.h
@@ -63,5 +63,8 @@ extern SaNameT logSvcUsrName;
 extern SaLogRecordT genLogRecord;
 extern char log_root_path[];
 
+/* Same as system() but returns WEXITSTATUS if not -1 */
+int tet_system(const char *command);
+
 int get_active_sc(void);
 #endif
diff --git a/tests/logsv/tet_LogOiOps.c b/tests/logsv/tet_LogOiOps.c
--- a/tests/logsv/tet_LogOiOps.c
+++ b/tests/logsv/tet_LogOiOps.c
@@ -946,14 +946,59 @@ void saLogOi_52(void)
  */
 void saLogOi_48(void)
 {
-    int rc;
+    int rc = 0, tst_stat = 0;
     char command[256];
-       
-    sprintf(command, "mkdir -p %s/xxtest",log_root_path);
-    rc = system(command);
-    sprintf(command, "immcfg -a logRootDirectory=%s/xxtest 
logConfig=1,safApp=safLogService",log_root_path);
-    rc = system(command);
-    rc_validate(WEXITSTATUS(rc), 0);
+    char tstdir[256];
+
+    /* Path to test directory */
+    sprintf(tstdir, "%s/xxtest", log_root_path);
+
+    /* Create test directory */
+    sprintf(command, "mkdir -p %s", tstdir);
+    rc = tet_system(command);
+    if (rc != 0) {
+           fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+           tst_stat = 1;
+           goto done;
+    }
+    /* Make sure it can be accessed by server */
+    sprintf(command, "chmod ugo+w,ugo+r %s", tstdir);
+    rc = tet_system(command);
+    if (rc != 0) {
+           fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+           tst_stat = 1;
+           goto done;
+    }
+
+    /* Change to xxtest */
+    sprintf(command, "immcfg -a logRootDirectory=%s 
logConfig=1,safApp=safLogService",tstdir);
+    rc = tet_system(command);
+    if (rc != 0) {
+           fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+           tst_stat = 1;
+           goto done_remove;
+    }
+
+    /* Change back */
+    sprintf(command, "immcfg -a logRootDirectory=%s 
logConfig=1,safApp=safLogService",log_root_path);
+    rc = tet_system(command);
+    if (rc != 0) {
+           fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+           tst_stat = 1;
+           goto done_remove;
+    }
+
+    done_remove:
+    /* Remove xxtest no longer used */
+    sprintf(command, "rm -rf %s/", tstdir);
+    rc = tet_system(command);
+    if (rc != 0) {
+           fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+           goto done;
+    }
+
+    done:
+    rc_validate(tst_stat, 0);
 }
 
 /**
@@ -1374,7 +1419,7 @@ void saLogOi_72(void)
  */
 void saLogOi_73(void)
 {
-       int rc;
+       int rc = 0, tst_stat = 0;
        char command[512];
        
        sprintf(command, "immcfg -c SaLogStreamConfig"
@@ -1382,11 +1427,24 @@ void saLogOi_73(void)
                " -a saLogStreamFileName=str6file -a saLogStreamPathName=."
                " -a saLogStreamFixedLogRecordSize=%d",
                        MAX_LOGRECSIZE);
-       rc = system(command);
+       rc = tet_system(command);
+       if (rc != 0) {
+               fprintf(stderr, "%s Fail rc=%d\n", command, rc);
+               tst_stat = 1;
+               goto done;
+       }
+
        /* Delete the test object */
        sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
-       safassert(system(command),0);
-       rc_validate(WEXITSTATUS(rc), 0);
+       rc = tet_system(command);
+       if (rc != 0) {
+               fprintf(stderr, "%s Fail rc=%d\n", command, rc);
+               tst_stat = 1;
+               goto done;
+       }
+
+       done:
+       rc_validate(tst_stat, 0);
 }
 
 /**
@@ -1394,7 +1452,7 @@ void saLogOi_73(void)
  */
 void saLogOi_74(void)
 {
-       int rc;
+       int rc = 0, tst_stat = 0;
        char command[512];
        
        sprintf(command, "immcfg -c SaLogStreamConfig"
@@ -1402,11 +1460,20 @@ void saLogOi_74(void)
                " -a saLogStreamFileName=str6file -a saLogStreamPathName=."
                " -a saLogStreamFixedLogRecordSize=%d",
                        0);
-       rc = system(command);
+       rc = tet_system(command);
+       if (rc != 0) {
+               fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+               tst_stat = 1;
+       }
        /* Delete the test object */
        sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
-       safassert(system(command),0);
-       rc_validate(WEXITSTATUS(rc), 0);
+       rc = tet_system(command);
+       if (rc != 0) {
+               fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+               tst_stat = 1;
+       }
+
+       rc_validate(tst_stat, 0);
 }
 
 /**

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to