Sean Wilson has uploaded this change for review. (
https://gem5-review.googlesource.com/4423
Change subject: tests: Add test for the m5-exit instruction.
......................................................................
tests: Add test for the m5-exit instruction.
Change-Id: I92a589b267ce659b6fbcf710043436b84fcb1c63
Signed-off-by: Sean Wilson <spwils...@wisc.edu>
---
A tests/gem5/m5_util/test_exit.py
A tests/test-progs/m5-exit/Makefile
A tests/test-progs/m5-exit/bin/X86/linux/.gitignore
A tests/test-progs/m5-exit/src/.gitignore
A tests/test-progs/m5-exit/src/m5-exit.c
M util/m5/Makefile.x86
6 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/tests/gem5/m5_util/test_exit.py
b/tests/gem5/m5_util/test_exit.py
new file mode 100644
index 0000000..d34a7c1
--- /dev/null
+++ b/tests/gem5/m5_util/test_exit.py
@@ -0,0 +1,22 @@
+'''
+Test file for the util m5 exit assembly instruction.
+'''
+import re
+import os
+from testlib import *
+
+m5_exit_regex = re.compile(
+r'Exiting @ tick \d* because m5_exit instruction encountered'
+)
+
+test_program = TestProgram('m5-exit', 'X86', 'linux')
+
+a = verifier.MatchRegex(m5_exit_regex)
+gem5_verify_config(
+ name='m5_exit_test',
+ verifiers=[a],
+ fixtures=(test_program,),
+ config=os.path.join(config.base_dir, 'configs', 'example','se.py'),
+ config_args=['--cmd', test_program.path],
+ valid_isas=('X86',)
+)
diff --git a/tests/test-progs/m5-exit/Makefile
b/tests/test-progs/m5-exit/Makefile
new file mode 100644
index 0000000..b5264e9
--- /dev/null
+++ b/tests/test-progs/m5-exit/Makefile
@@ -0,0 +1,16 @@
+M5_UTIL:=${CURDIR}/../../../util/m5
+M5_INCLUDE:=${CURDIR}/../../../include/
+
+# Export CFLAGS so that subMAKEs don't define any flags we don't want.
+CFLAGS=-I ${M5_INCLUDE} -O2
+export CFLAGS
+
+bin/X86/linux/m5-exit: src/m5-exit.c ${M5_UTIL}/m5op_x86.o
+ gcc -DM5 $< ${M5_UTIL}/m5op_x86.o ${CFLAGS} -o $@
+
+${M5_UTIL}/m5op_x86.o:
+ $(MAKE) -C ${M5_UTIL} -f Makefile.x86 m5op_x86.o
+
+clean:
+ rm -f m5-exit m5op.h
+ $(MAKE) -C ${M5_UTIL} -f Makefile.x86 clean
diff --git a/tests/test-progs/m5-exit/bin/X86/linux/.gitignore
b/tests/test-progs/m5-exit/bin/X86/linux/.gitignore
new file mode 100644
index 0000000..1bcdf2d
--- /dev/null
+++ b/tests/test-progs/m5-exit/bin/X86/linux/.gitignore
@@ -0,0 +1 @@
+m5-exit
diff --git a/tests/test-progs/m5-exit/src/.gitignore
b/tests/test-progs/m5-exit/src/.gitignore
new file mode 100644
index 0000000..65c4e2f
--- /dev/null
+++ b/tests/test-progs/m5-exit/src/.gitignore
@@ -0,0 +1 @@
+m5op.h
\ No newline at end of file
diff --git a/tests/test-progs/m5-exit/src/m5-exit.c
b/tests/test-progs/m5-exit/src/m5-exit.c
new file mode 100644
index 0000000..8d8a2b7
--- /dev/null
+++ b/tests/test-progs/m5-exit/src/m5-exit.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+#ifdef M5
+#include "m5op.h"
+
+// If you need to define this, you should have removed the -DM5OP_ADDR
+// when compiling the m5op_x86.o
+//void *m5_mem = (void*)0xCAFEBABE;
+#endif
+
+int main() {
+ #ifdef M5
+ m5_exit(0);
+ #endif
+ printf("FAIL!\n");
+ printf("Program should have exited due to the magic m5_exit"
+ " instruction!\n");
+ return -1;
+}
diff --git a/util/m5/Makefile.x86 b/util/m5/Makefile.x86
index 5ea29cc..e1388c2 100644
--- a/util/m5/Makefile.x86
+++ b/util/m5/Makefile.x86
@@ -31,7 +31,7 @@
AS=as
LD=ld
-CFLAGS=-O2 -DM5OP_ADDR=0xFFFF0000 -I$(PWD)/../../include
+CFLAGS?=-O2 -DM5OP_ADDR=0xFFFF0000 -I$(PWD)/../../include
OBJS=m5.o m5op_x86.o
all: m5
--
To view, visit https://gem5-review.googlesource.com/4423
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92a589b267ce659b6fbcf710043436b84fcb1c63
Gerrit-Change-Number: 4423
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Wilson <spwils...@wisc.edu>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev