Browse Source

riscv: Add a test for getcallerpc

It doesn't work yet because inline only happens with -O2 or such.
But at least it's there.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 2 years ago
parent
commit
7ae80719bb
3 changed files with 43 additions and 0 deletions
  1. 1 0
      sys/src/9/riscv/build.json
  2. 1 0
      sys/src/regress/build.json
  3. 41 0
      sys/src/regress/getcallerpc.c

+ 1 - 0
sys/src/9/riscv/build.json

@@ -69,6 +69,7 @@
 				"echo": "/$ARCH/bin/echo",
 				"empty": "/$ARCH/bin/regress/empty",
 				"factotum": "/$ARCH/bin/auth/factotum",
+				"getcallerpc": "/$ARCH/bin/regress/getcallerpc",
 				"ipconfig": "/$ARCH/bin/ip/ipconfig",
 				"longjmp": "/$ARCH/bin/regress/longjmp",
 				"ls": "/$ARCH/bin/ls",

+ 1 - 0
sys/src/regress/build.json

@@ -21,6 +21,7 @@
 			"fmt.c",
 			"fork.c",
 			"frexp.c",
+			"getcallerpc.c",
 			"iphash.c",
 			"hcube.c",
 			"lockdeath.c",

+ 41 - 0
sys/src/regress/getcallerpc.c

@@ -0,0 +1,41 @@
+#include <u.h>
+#include <libc.h>
+
+/*
+ * Do nothing. We can't exits from this one. It tests correctness of programs
+ * that just return.
+ */
+
+void c(void);
+void b(void);
+
+void a(void)
+{
+	uintptr_t d = getcallerpc()
+;
+	fprint(2, "This should print something more than %p and less than %p: %p\n",
+		b, c, d);
+	if ((d > b) && (d < c)) {
+		print("PASS\n");
+		exits("PASS");
+		return;
+	}
+	print("FAIL\n");
+	exits("FAIL");
+}
+
+void b(void)
+{
+	a();
+}
+
+void c(void)
+{
+	b();
+}
+
+void
+main(int argc, char *argv[])
+{
+	c();
+}