aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/vm/pt-grow-stk-sc.c
diff options
context:
space:
mode:
authorklaar36 <klas.arvidsson@liu.se>2015-03-20 17:30:24 +0100
committerklaar36 <klas.arvidsson@liu.se>2015-03-20 17:30:24 +0100
commite7bc50ca8ffcaa6ed68ebd2315f78b0f5a7d10ad (patch)
tree4de97af7207676b69cb6a9aba8cb443cc134855d /src/tests/vm/pt-grow-stk-sc.c
parentb0418a24e709f0632d2ede5b0f327c422931939b (diff)
downloadpintos-rs-e7bc50ca8ffcaa6ed68ebd2315f78b0f5a7d10ad.tar.gz
Initial Pintos
Diffstat (limited to 'src/tests/vm/pt-grow-stk-sc.c')
-rw-r--r--src/tests/vm/pt-grow-stk-sc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tests/vm/pt-grow-stk-sc.c b/src/tests/vm/pt-grow-stk-sc.c
new file mode 100644
index 0000000..3efbb5f
--- /dev/null
+++ b/src/tests/vm/pt-grow-stk-sc.c
@@ -0,0 +1,32 @@
+/* This test checks that the stack is properly extended even if
+ the first access to a stack location occurs inside a system
+ call.
+
+ From Godmar Back. */
+
+#include <string.h>
+#include <syscall.h>
+#include "tests/vm/sample.inc"
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void)
+{
+ int handle;
+ int slen = strlen (sample);
+ char buf2[65536];
+
+ /* Write file via write(). */
+ CHECK (create ("sample.txt", slen), "create \"sample.txt\"");
+ CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
+ CHECK (write (handle, sample, slen) == slen, "write \"sample.txt\"");
+ close (handle);
+
+ /* Read back via read(). */
+ CHECK ((handle = open ("sample.txt")) > 1, "2nd open \"sample.txt\"");
+ CHECK (read (handle, buf2 + 32768, slen) == slen, "read \"sample.txt\"");
+
+ CHECK (!memcmp (sample, buf2 + 32768, slen), "compare written data against read data");
+ close (handle);
+}