summaryrefslogtreecommitdiff
path: root/410user/progs/exec_nonexist.c
diff options
context:
space:
mode:
authorHanjie Wu <hanjiew@andrew.cmu.edu>2023-04-18 02:21:10 -0400
committerHanjie Wu <hanjiew@andrew.cmu.edu>2023-04-18 02:21:10 -0400
commitc71294cdd3581c3738d24ffd65414f8644a1094d (patch)
treec86245d50fad9eee4163dbba169bd1839edbf88f /410user/progs/exec_nonexist.c
initial commit
Diffstat (limited to '410user/progs/exec_nonexist.c')
-rw-r--r--410user/progs/exec_nonexist.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/410user/progs/exec_nonexist.c b/410user/progs/exec_nonexist.c
new file mode 100644
index 0000000..f2cb8dd
--- /dev/null
+++ b/410user/progs/exec_nonexist.c
@@ -0,0 +1,31 @@
+/** @file 410user/progs/exec_nonexist.c
+ * @author mpa
+ * @brief Tests exec()ing a nonexistent file.
+ * @public yes
+ * @for p3
+ * @covers exec
+ * @status done
+ */
+
+#include <syscall.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "410_tests.h"
+#include <report.h>
+
+DEF_TEST_NAME("exec_nonexist:");
+
+int main() {
+ char *name = "exec_a_random_file_that_does_not_exist";
+ char *args[] = {name, 0};
+ report_start(START_CMPLT);
+
+ if (exec(name,args) >= 0) {
+ report_misc("exec() did not return an error code");
+ report_end(END_FAIL);
+ exit(-1);
+ }
+
+ report_end(END_SUCCESS);
+ exit(0);
+}