Brandon Potter has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/17112

Change subject: sim-se, tests: add a new sim-se test
......................................................................

sim-se, tests: add a new sim-se test

This changeset adds a test to check the redirection features
added in faux-filesystem changeset. The test contains a
"chdir" system call to "/proc" which should be redirected to
"$(gem5-dir)/m5out/fs/proc" (as specified by the config files).

After "chdir", the test subsequently outputs the "/proc/cpuinfo"
file which should output a configuration of a fake cpu with
values set by a Python configuration file.

Note, the test will call "clone" once. To avoid a runtime error,
make sure that you run this test with "-n2" supplied to the
"config/example/se.py" script.

Change-Id: I505b046b7a4feddfa93a6ef0f0773ac43078cc94
---
A tests/test-progs/chdir-print/Makefile
A tests/test-progs/chdir-print/chdir-print.c
2 files changed, 50 insertions(+), 0 deletions(-)



diff --git a/tests/test-progs/chdir-print/Makefile b/tests/test-progs/chdir-print/Makefile
new file mode 100644
index 0000000..6a357d5
--- /dev/null
+++ b/tests/test-progs/chdir-print/Makefile
@@ -0,0 +1,20 @@
+
+CPP := g++
+
+TEST_OBJS := chdir-print.o
+TEST_PROGS := $(TEST_OBJS:.o=)
+
+# ==== Rules ==================================================================
+
+.PHONY: default clean
+
+default: $(TEST_PROGS)
+
+clean:
+       $(RM)  $(TEST_OBJS) $(TEST_PROGS)
+
+$(TEST_PROGS): $(TEST_OBJS)
+       $(CPP)  -static -o $@  [email protected]
+
+%.o: %.c Makefile
+       $(CPP) -c -o $@ $*.c -msse3
diff --git a/tests/test-progs/chdir-print/chdir-print.c b/tests/test-progs/chdir-print/chdir-print.c
new file mode 100644
index 0000000..0cf56f9
--- /dev/null
+++ b/tests/test-progs/chdir-print/chdir-print.c
@@ -0,0 +1,30 @@
+#include <linux/limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+const int BUFFER_SIZE = 64;
+
+int main(void)
+{
+    char *cwd = getcwd(NULL, PATH_MAX);
+    printf("cwd: %s\n", cwd);
+    free(cwd);
+
+    chdir("/proc");
+
+    cwd = getcwd(NULL, PATH_MAX);
+    printf("cwd: %s\n", cwd);
+    free(cwd);
+
+    FILE *fp;
+    char buffer[BUFFER_SIZE];
+    fp = popen("cat cpuinfo", "r");
+    if (fp != NULL) {
+        while (fgets(buffer, BUFFER_SIZE, fp) != NULL)
+            printf("%s", buffer);
+        pclose(fp);
+    }
+
+    return 0;
+}

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/17112
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I505b046b7a4feddfa93a6ef0f0773ac43078cc94
Gerrit-Change-Number: 17112
Gerrit-PatchSet: 1
Gerrit-Owner: Brandon Potter <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to