aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eztester.c23
-rw-r--r--eztester.h11
2 files changed, 28 insertions, 6 deletions
diff --git a/eztester.c b/eztester.c
index 60737cb..6cafbea 100644
--- a/eztester.c
+++ b/eztester.c
@@ -166,6 +166,7 @@ void eztester_run(eztester_list *test_list, eztester_behavior behavior) {
_ez_premature_exit("Warning occured, Exitting", pid, i + 1, pass_count,
length);
}
+ pass_count++;
break;
case TEST_FAIL:
@@ -198,6 +199,28 @@ void eztester_run(eztester_list *test_list, eztester_behavior behavior) {
}
}
+int eztester_shell(const char *command) {
+ int result;
+ if (command == NULL) {
+ eztester_log("Recieved NULL as command, checking for shell availability");
+ result = !system(command);
+ eztester_log("Shell %s available", (result) ? "is not" : "is");
+ return result;
+ }
+
+ eztester_log("Executing %s", command);
+ result = system(command);
+ if(result == -1){
+ eztester_log("Error with child process");
+ perror(command);
+ }
+ else {
+ eztester_log("Process exited with a status of %d", result);
+ }
+
+ return result;
+}
+
void eztester_log(const char *restrict format, ...) {
va_list args;
va_start(args, format);
diff --git a/eztester.h b/eztester.h
index ca8d4af..682d348 100644
--- a/eztester.h
+++ b/eztester.h
@@ -45,14 +45,13 @@ void eztester_log(const char *__restrict format, ...);
// run all tests with a list with a given behavior
void eztester_run(eztester_list *test_list, const eztester_behavior behavior);
-/* Run a shell script found at file_path, it can read in from input and write to
- * output
+/* Wrapper for `system` function
*
- * Returns exit code of the command
- * UNIMPLEMENTED!
+ * if command is null return the availability of a shell (negated result of system's behavior)
+ *
+ * If command is not null return the exit status of the process
*/
-unsigned char ezteser_run_shell_script(const char *file_path, FILE *input,
- FILE *output);
+int eztester_shell(const char *command);
// tests that always return an eztester_status