diff --git a/test161/commands/asst2.tc b/test161/commands/asst2.tc new file mode 100644 index 0000000..cb92079 --- /dev/null +++ b/test161/commands/asst2.tc @@ -0,0 +1,86 @@ +templates: + - name: /testbin/consoletest + panics: maybe + output: + - text: "/testbin/consoletest: Able was i ere i saw elbA" + + + - name: /testbin/opentest + panics: maybe + + - name: /testbin/readwritetest + panics: maybe + output: + - text: "/testbin/readwritetest: h4xa0rRq0Vgbc96tiYJ^!#nXzZSAKPO" + + - name: /testbin/closetest + panics: maybe + + + - name: /testbin/fileonlytest + panics: maybe + + - name: /testbin/redirect + + - name: /testbin/sparsefile + panics: maybe + + - name: /extratests/badcall + - name: faulter + + + - name: /testbin/forkbomb + timesout: yes + timeout: 15.0 + output: + - text: "kmalloc" + external: true + trusted: true + - name: kmalloc + output: + - text: "kmalloc: out of memory" + + + - name: /testbin/crash + - name: /testbin/forktest + - name: /testbin/randcall + + - name: /testbin/shelltest + output: + - text: "/testbin/shelltest: line-1: Able was i ere i saw elbA" + - text: "/testbin/shelltest: line-2: Able was i ere i saw elbA" + - text: "/testbin/shelltest: line-3: Able was i ere i saw elbA" + + + - name: /testbin/argtest + input: + - "{{randString 1 2}}" + - "{{randString 4 5}}" + - "{{randString 9 10}}" + - "{{randString 10 11}}" + - "{{randString 11 12}}" + - "{{randString 12 13}}" + - "{{randString 13 14}}" + - "{{randString 200 513}}" + output: + - text: "/testbin/argtest: argc: {{add 1 .ArgLen}}" + - text: "/testbin/argtest: /testbin/argtest" + - text: "{{range $index, $element := .Args}}/testbin/argtest: {{$element}}\n{{end}}" + - text: "/testbin/argtest: [NULL]" + + - name: /testbin/bigexec + + - name: /testbin/factorial + input: + - "{{randInt 6 10}}" + output: + - text: "/testbin/factorial: {{$n:= index .Args 0 | atoi}}{{factorial $n}}\n" + + - name: /testbin/add + input: + - "{{randInt 2 1000}}" + - "{{randInt 2 4000}}" + output: + - text: "/testbin/add: {{$x:= index .Args 0 | atoi}}{{$y := index .Args 1 | atoi}}{{add $x $y}}" + + diff --git a/test161/targets/asst2.tt b/test161/targets/asst2.tt new file mode 100644 index 0000000..1ace305 --- /dev/null +++ b/test161/targets/asst2.tt @@ -0,0 +1,76 @@ +name: asst2 +version: 1 +points: 150 +type: asst +kconfig: ASST2 +userland: true +tests: +# FS tests + - id: asst2/fs/consoletest.t + points: 2 + - id: asst2/fs/opentest.t + points: 5 + - id: asst2/fs/closetest.t + points: 3 + - id: asst2/fs/readwritetest.t + points: 10 + - id: asst2/fs/fileonlytest.t + points: 15 + - id: asst2/fs/redirect.t + points: 10 + - id: asst2/fs/sparsefile.t + points: 5 + +# Process tests + - id: asst2/process/forktest.t + points: 15 + - id: asst2/process/shell.t + points: 10 + - id: asst2/process/argtest.t + points: 5 + - id: asst2/process/bigexec.t + points: 10 + - id: asst2/process/factorial.t + points: 5 + - id: asst2/process/add.t + points: 5 + +# All tests below this point are stability tests + +# badcalls + - id: asst2/stability/badcall/badcall-open.t + points: 3 + - id: asst2/stability/badcall/badcall-close.t + points: 3 + - id: asst2/stability/badcall/badcall-read.t + points: 3 + - id: asst2/stability/badcall/badcall-write.t + points: 3 + - id: asst2/stability/badcall/badcall-lseek.t + points: 3 + - id: asst2/stability/badcall/badcall-dup2.t + points: 3 + - id: asst2/stability/badcall/badcall-execv.t + points: 5 + - id: asst2/stability/badcall/badcall-waitpid.t + points: 5 + + - id: asst2/stability/crash/crash-allS.t + points: 2 + + - id: asst2/stability/randcall.t + points: 5 + commands: + - id: /testbin/randcall + args: + - "-f" + - "-c 1000" + - "-r {{randInt 1 4294967295}}" + - "2" + + - id: asst2/stability/forkbomb.t + points: 10 + + - id: asst2/stability/forktest-stability.t + points: 5 + diff --git a/test161/tests/asst2/fs/closetest.t b/test161/tests/asst2/fs/closetest.t new file mode 100644 index 0000000..85fc67d --- /dev/null +++ b/test161/tests/asst2/fs/closetest.t @@ -0,0 +1,8 @@ +--- +name: "Close Test" +description: + Tests close syscall. Attempts to close stdin and a normal file. +tags: [fs] +depends: [boot, /asst2/fs/opentest.t] +--- +p /testbin/closetest diff --git a/test161/tests/asst2/fs/consoletest.t b/test161/tests/asst2/fs/consoletest.t new file mode 100644 index 0000000..e12af0a --- /dev/null +++ b/test161/tests/asst2/fs/consoletest.t @@ -0,0 +1,8 @@ +--- +name: "Console Test" +tags: [console] +depends: [boot] +sys161: + ram: 4M +--- +p /testbin/consoletest diff --git a/test161/tests/asst2/fs/fileonlytest.t b/test161/tests/asst2/fs/fileonlytest.t new file mode 100644 index 0000000..34f2309 --- /dev/null +++ b/test161/tests/asst2/fs/fileonlytest.t @@ -0,0 +1,13 @@ +--- +name: "Fileonly Test" +description: + Tests open/close/read/write/lseek system calls. Opens file, writes 512 + bytes, skips 512 bytes and writes another 512 bytes(odd steps). Then seeks + back to beginning, and writes the even steps. Then seeks back to the + beginning and verifies that the contents are correct. +tags: [fs] +depends: [console, /asst2/fs/readwritetest.t,] +sys161: + ram: 4M +--- +p /testbin/fileonlytest diff --git a/test161/tests/asst2/fs/opentest.t b/test161/tests/asst2/fs/opentest.t new file mode 100644 index 0000000..ae4db90 --- /dev/null +++ b/test161/tests/asst2/fs/opentest.t @@ -0,0 +1,8 @@ +--- +name: "Open Test" +description: + Tests open syscall. Attempts to open a file that is known to exist. +tags: [fs] +depends: [boot] +--- +p /testbin/opentest diff --git a/test161/tests/asst2/fs/readwritetest.t b/test161/tests/asst2/fs/readwritetest.t new file mode 100644 index 0000000..37107fc --- /dev/null +++ b/test161/tests/asst2/fs/readwritetest.t @@ -0,0 +1,9 @@ +--- +name: "Read-Write Test" +description: + Tests read and write syscalls. Attempts to write a file and then + read it back. +tags: [fs] +depends: [/asst2/fs/opentest.t] +--- +p /testbin/readwritetest diff --git a/test161/tests/asst2/fs/redirect.t b/test161/tests/asst2/fs/redirect.t new file mode 100644 index 0000000..8a17a58 --- /dev/null +++ b/test161/tests/asst2/fs/redirect.t @@ -0,0 +1,11 @@ +--- +name: "Redirect Test" +description: + Tests dup2. Opens a file handle, forks a new process and manipulates the file + table using dup2. +tags: [fs] +depends: [/asst2/process/forktest.t] +sys161: + ram: 4M +--- +p /testbin/redirect diff --git a/test161/tests/asst2/fs/sparsefile.t b/test161/tests/asst2/fs/sparsefile.t new file mode 100644 index 0000000..20a8609 --- /dev/null +++ b/test161/tests/asst2/fs/sparsefile.t @@ -0,0 +1,11 @@ +--- +name: "Sparsefile Test" +description: + Tests lseek to write one byte of data after skipping the first x bytes + in an empty file. Then attempts to read this byte. +tags: [fs] +depends: [shell, /asst2/fs/fileonlytest.t] +sys161: + ram: 2M +--- +$ /testbin/sparsefile test 1048 diff --git a/test161/tests/asst2/process/add.t b/test161/tests/asst2/process/add.t new file mode 100644 index 0000000..849ee13 --- /dev/null +++ b/test161/tests/asst2/process/add.t @@ -0,0 +1,8 @@ +--- +name: "Add Test" +description: + Adds two randomly generated numbers. +tags: [proc, fun] +depends: [shell] +--- +$ /testbin/add diff --git a/test161/tests/asst2/process/argtest.t b/test161/tests/asst2/process/argtest.t new file mode 100644 index 0000000..cf6e38b --- /dev/null +++ b/test161/tests/asst2/process/argtest.t @@ -0,0 +1,8 @@ +--- +name: "Argtest" +description: + Checks whether your kernel supports argument passing. +tags: [argtest, proc] +depends: [console] +--- +$ /testbin/argtest diff --git a/test161/tests/asst2/process/bigexec.t b/test161/tests/asst2/process/bigexec.t new file mode 100644 index 0000000..c2b2a40 --- /dev/null +++ b/test161/tests/asst2/process/bigexec.t @@ -0,0 +1,11 @@ +--- +name: "Bigexec Test" +description: + Tests to ensure that the argument passing logic is not hard-coded + to small argument lengths. +tags: [proc] +depends: [shell, /asst2/process/argtest.t] +sys161: + ram: 4M +--- +$ /testbin/bigexec diff --git a/test161/tests/asst2/process/factorial.t b/test161/tests/asst2/process/factorial.t new file mode 100644 index 0000000..b1aaea1 --- /dev/null +++ b/test161/tests/asst2/process/factorial.t @@ -0,0 +1,11 @@ +--- +name: "Factorial Test" +description: + Attempts to calculate factorial by recursive replacing the current process + with the number computed thus far. +tags: [proc, fun] +depends: [shell] +sys161: + ram: 4M +--- +$ /testbin/factorial diff --git a/test161/tests/asst2/process/forktest.t b/test161/tests/asst2/process/forktest.t new file mode 100644 index 0000000..2d1a808 --- /dev/null +++ b/test161/tests/asst2/process/forktest.t @@ -0,0 +1,8 @@ +--- +name: "Fork Test" +tags: [proc] +depends: [console, /asst2/fs/readwritetest.t] +sys161: + ram: 4M +--- +p /testbin/forktest diff --git a/test161/tests/asst2/process/shell.t b/test161/tests/asst2/process/shell.t new file mode 100644 index 0000000..ea9cac8 --- /dev/null +++ b/test161/tests/asst2/process/shell.t @@ -0,0 +1,13 @@ +--- +name: "Shell Test" +description: + Tests whether the shell works by running /testbin/consoletest in the shell. + The shell test tries to identify a race condition between the shell and the + program that the shell is trying to run. +tags: [proc, shell] +depends: [console] +sys161: + ram: 2M +--- +$ /testbin/shelltest +$ /testbin/shelltest diff --git a/test161/tests/asst2/stability/badcall/badcall-close.t b/test161/tests/asst2/stability/badcall/badcall-close.t new file mode 100644 index 0000000..ba2ac4e --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-close.t @@ -0,0 +1,9 @@ +--- +name: "Badcall-close Test" +description: + Tests whether close syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +--- +$ /testbin/badcall f diff --git a/test161/tests/asst2/stability/badcall/badcall-dup2.t b/test161/tests/asst2/stability/badcall/badcall-dup2.t new file mode 100644 index 0000000..7965c70 --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-dup2.t @@ -0,0 +1,9 @@ +--- +name: "Badcall-dup2 Test" +description: + Tests whether dup2 syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +--- +$ /testbin/badcall w diff --git a/test161/tests/asst2/stability/badcall/badcall-execv.t b/test161/tests/asst2/stability/badcall/badcall-execv.t new file mode 100644 index 0000000..0e74dbe --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-execv.t @@ -0,0 +1,11 @@ +--- +name: "Badcall-execv Test" +description: + Tests whether execv syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +sys161: + ram: 4M +--- +$ /testbin/badcall a diff --git a/test161/tests/asst2/stability/badcall/badcall-lseek.t b/test161/tests/asst2/stability/badcall/badcall-lseek.t new file mode 100644 index 0000000..404be2a --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-lseek.t @@ -0,0 +1,9 @@ +--- +name: "Badcall-lseek Test" +description: + Tests whether lseek syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +--- +$ /testbin/badcall j diff --git a/test161/tests/asst2/stability/badcall/badcall-open.t b/test161/tests/asst2/stability/badcall/badcall-open.t new file mode 100644 index 0000000..fc1daa3 --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-open.t @@ -0,0 +1,9 @@ +--- +name: "Badcall-open Test" +description: + Tests whether open syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +--- +$ /testbin/badcall c diff --git a/test161/tests/asst2/stability/badcall/badcall-read.t b/test161/tests/asst2/stability/badcall/badcall-read.t new file mode 100644 index 0000000..6cf608f --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-read.t @@ -0,0 +1,9 @@ +--- +name: "Badcall-read Test" +description: + Tests whether read syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +--- +$ /testbin/badcall d diff --git a/test161/tests/asst2/stability/badcall/badcall-waitpid.t b/test161/tests/asst2/stability/badcall/badcall-waitpid.t new file mode 100644 index 0000000..0b2038e --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-waitpid.t @@ -0,0 +1,11 @@ +--- +name: "Badcall-waitpid Test" +description: + Tests whether waitpid syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +sys161: + ram: 4M +--- +$ /testbin/badcall b diff --git a/test161/tests/asst2/stability/badcall/badcall-write.t b/test161/tests/asst2/stability/badcall/badcall-write.t new file mode 100644 index 0000000..77be1ad --- /dev/null +++ b/test161/tests/asst2/stability/badcall/badcall-write.t @@ -0,0 +1,9 @@ +--- +name: "Badcall-write Test" +description: + Tests whether write syscall is implemented correctly by invoking it in all + possible wrong ways. +tags: [badcall, stability] +depends: [shell] +--- +$ /testbin/badcall e diff --git a/test161/tests/asst2/stability/crash/crash-allS.t b/test161/tests/asst2/stability/crash/crash-allS.t new file mode 100644 index 0000000..54cf02e --- /dev/null +++ b/test161/tests/asst2/stability/crash/crash-allS.t @@ -0,0 +1,13 @@ +--- +name: "Crash-all Shell Test" +description: + Tests whether your system correctly handles a variety of + illegal attempts from userspace processes to access resources that + do not belong to it. Please see userland/testbin/crash for more info. + Runs it from the shell. +tags: [stability, crash, crash-fork] +depends: [shell, /asst2/process/forktest.t] +sys161: + ram: 4M +--- +$ /testbin/crash * diff --git a/test161/tests/asst2/stability/crash/crash-template b/test161/tests/asst2/stability/crash/crash-template new file mode 100644 index 0000000..db8368a --- /dev/null +++ b/test161/tests/asst2/stability/crash/crash-template @@ -0,0 +1,10 @@ +--- +name: "Crash-template Test" +description: + Tests whether your system correctly handles a variety of + illegal attempts from userspace processes to access resources that + do not belong to it. Please see userland/testbin/crash for more info. +tags: [stability, crash] +depends: [console] +--- +p /extratests/crash-template diff --git a/test161/tests/asst2/stability/crash/script.py b/test161/tests/asst2/stability/crash/script.py new file mode 100644 index 0000000..9b3bb32 --- /dev/null +++ b/test161/tests/asst2/stability/crash/script.py @@ -0,0 +1,54 @@ +import os,sys +import subprocess + +RANGE=[chr(i) for i in range(ord('a'), ord('p'))] + +# First create crash-a/b/c.t files +template = open('crash-template').read() + +def add_sys161_opts(content, sys161_opts): + content = content.split('\n') + idx = content[1:].index('---') + 1 + content.insert(idx, sys161_opts.strip()) + content = '\n'.join(content) + return content + +def create_crash(char, sys161_opts=None): + content = template.replace('-template', '-%s' % char) + content = content.replace(', crash]', ', crash-fork]') + content = content.replace('[console]', '[console, /asst2/process/forktest.t]') + if sys161_opts: + content = add_sys161_opts(content, sys161_opts) + + with open('crash-%s.t' % char, 'w') as f: + f.write(content) + + # now do the F version + content = template.replace('-template', '-%sF' % char) + if sys161_opts: + content = add_sys161_opts(content, sys161_opts) + with open('crash-%sF.t' % char, 'w') as f: + f.write(content) + +for char in RANGE: + create_crash(char) + +# Now do the 'all' +sys161_opts = \ +''' +sys161: + ram: 2M +''' +create_crash('all', sys161_opts) + +#p = subprocess.Popen('ls *.t', shell=True, stdout=subprocess.PIPE) +#stdout, stderr = p.communicate() +#files = stdout.strip().split('\n') +# +#for f in files: +# name, ext = os.path.splitext(f) +# +# new_file = name + 'F' + ext +# letters = name[name.index('-'):] +# subprocess.check_call('cp %s %s' % (f, new_file), shell=True) +# subprocess.check_call('''sed -i 's/%s/%sF/g' %s''' % (letters, letters, new_file), shell=True) diff --git a/test161/tests/asst2/stability/faulter.t b/test161/tests/asst2/stability/faulter.t new file mode 100644 index 0000000..798c47d --- /dev/null +++ b/test161/tests/asst2/stability/faulter.t @@ -0,0 +1,10 @@ +--- +name: "Faulter Test" +description: + Tests whether kill_curthread is implemented correctly. + Attempts to access an invalid memory address expecting the kernel + to gracefully kill the current process instead of panicking. +tags: [proc] +depends: [console] +--- +p /testbin/faulter diff --git a/test161/tests/asst2/stability/forkbomb.t b/test161/tests/asst2/stability/forkbomb.t new file mode 100644 index 0000000..7b82941 --- /dev/null +++ b/test161/tests/asst2/stability/forkbomb.t @@ -0,0 +1,10 @@ +--- +name: "Forkbomb" +tags: [stability] +depends: [console] +sys161: + ram: 2M +monitor: + progresstimeout: 40.0 +--- +p /testbin/forkbomb diff --git a/test161/tests/asst2/stability/forktest-stability.t b/test161/tests/asst2/stability/forktest-stability.t new file mode 100644 index 0000000..f30d0fc --- /dev/null +++ b/test161/tests/asst2/stability/forktest-stability.t @@ -0,0 +1,14 @@ +--- +name: "Forktest Stability Test" +description: + Runs forktest 5 times to check for synchronization issues. +tags: [stability] +depends: [shell, /asst2/process/forktest.t] +sys161: + ram: 16M +--- +$ /testbin/forktest +$ /testbin/forktest +$ /testbin/forktest +$ /testbin/forktest +$ /testbin/forktest diff --git a/test161/tests/asst2/stability/randcall.t b/test161/tests/asst2/stability/randcall.t new file mode 100644 index 0000000..a9c60c1 --- /dev/null +++ b/test161/tests/asst2/stability/randcall.t @@ -0,0 +1,12 @@ +--- +name: "Randcall Test" +description: + Invokes system calls on random with random arguments. + Tests whether your system can gracefully recover from + bad system calls. +tags: [randcall-2, stability] +depends: [shell] +sys161: + ram: 16M +--- +$ /testbin/randcall -f -c 1000 -r 30 2