ESAPI-C 1.0
The OWASP Enterprise Security API for C
|
00001 #include <stdio.h> 00002 #include <string.h> 00003 #include "minunit.h" 00004 #include "executor.h" 00005 00006 int tests_run = 0; 00007 00008 /* 00009 * Note: This test is necessarily platform (UNIX in this case) specific 00010 */ 00011 void test_esapi_execute(void) 00012 { 00013 (void)fprintf(stdout, "Testing %s\n", __func__); 00014 00015 // FIXME: Need to find the correct directory for this file no matter what PWD is for the testing process. 00016 char *filename = "../configuration/ESAPI.properties"; 00017 char *params[] = {"-n 1", filename}; 00018 char *nave = "not_a_valid_execurable"; 00019 char *output = 0; 00020 00021 TEST((output = execute("head", params, 2, ".", pcodec_unix, true)) !=0); 00022 TEST(strcmp(output, "#\n") == 0); 00023 free(output); 00024 00025 TEST((output = execute(nave, params, 2, ".", pcodec_unix, true)) != 0); 00026 TEST(strcmp(output, "\0") == 0); 00027 free(output); 00028 00029 // char *p[] = {"abc123", "test-file.txt"}; 00030 // TEST((output = execute("grep", p, 2, ".", pcodec_unix, true)) !=0); 00031 // TEST(strcmp(output, "abc123\n") == 0); 00032 // free(output); 00033 } 00034 00035 int main(void) 00036 { 00037 test_esapi_execute(); 00038 00039 (void)fprintf(stdout, "%s: Pass <%i>, Fail<%i>\n", __FILE__, passed, failed); 00040 return(EXIT_SUCCESS); 00041 }