# -*- makefile -*-

tests/%.output: FILESYSSOURCE = --filesys-size=2
tests/%.output: PUTFILES = $(filter-out kernel.bin loader.bin, $^)

tests/userprog_TESTS = $(addprefix tests/userprog/,args-none		\
args-single args-multiple args-many args-dbl-space sc-bad-sp		\
sc-bad-arg sc-bad-num sc-boundary sc-boundary-2 halt exit create-normal		\
create-empty create-null create-bad-ptr create-long create-exists	\
create-bound open-normal open-missing open-boundary open-empty		\
open-null open-bad-ptr open-twice close-normal close-twice close-stdin	\
close-stdout close-bad-fd read-normal read-bad-ptr read-bad-buf read-boundary	\
read-zero read-stdout read-bad-fd write-normal write-bad-ptr write-bad-buf	\
write-boundary write-zero write-stdin write-bad-fd exec-once exec-arg	\
exec-large-arg exec-multiple exec-missing exec-over-arg exec-over-args \
exec-bad-ptr wait-simple wait-twice wait-killed wait-load-kill \
wait-bad-pid wait-bad-child multi-recurse multi-child-fd rox-simple	\
rox-child rox-multichild bad-read bad-write bad-read2 bad-write2        \
bad-jump bad-jump2 bad-maths overflow-stack)

tests/userprog_PROGS = $(tests/userprog_TESTS) $(addprefix \
tests/userprog/,child-simple child-args child-bad child-close child-rox exec-exit)

tests/userprog/args-none_SRC = tests/userprog/args.c
tests/userprog/args-single_SRC = tests/userprog/args.c
tests/userprog/args-multiple_SRC = tests/userprog/args.c
tests/userprog/args-many_SRC = tests/userprog/args.c
tests/userprog/args-dbl-space_SRC = tests/userprog/args.c
tests/userprog/sc-bad-sp_SRC = tests/userprog/sc-bad-sp.c tests/main.c
tests/userprog/sc-bad-arg_SRC = tests/userprog/sc-bad-arg.c tests/main.c
tests/userprog/sc-bad-num_SRC = tests/userprog/sc-bad-num.c tests/main.c
tests/userprog/bad-read_SRC = tests/userprog/bad-read.c tests/main.c
tests/userprog/bad-write_SRC = tests/userprog/bad-write.c tests/main.c
tests/userprog/bad-jump_SRC = tests/userprog/bad-jump.c tests/main.c
tests/userprog/bad-read2_SRC = tests/userprog/bad-read2.c tests/main.c
tests/userprog/bad-write2_SRC = tests/userprog/bad-write2.c tests/main.c
tests/userprog/bad-jump2_SRC = tests/userprog/bad-jump2.c tests/main.c
tests/userprog/bad-maths_SRC = tests/userprog/bad-maths.c tests/main.c
tests/userprog/overflow-stack_SRC = tests/userprog/overflow-stack.c tests/main.c
tests/userprog/sc-boundary_SRC = tests/userprog/sc-boundary.c	\
tests/userprog/boundary.c tests/main.c
tests/userprog/sc-boundary-2_SRC = tests/userprog/sc-boundary-2.c	\
tests/userprog/boundary.c tests/main.c
tests/userprog/halt_SRC = tests/userprog/halt.c tests/main.c
tests/userprog/exit_SRC = tests/userprog/exit.c tests/main.c
tests/userprog/create-normal_SRC = tests/userprog/create-normal.c tests/main.c
tests/userprog/create-empty_SRC = tests/userprog/create-empty.c tests/main.c
tests/userprog/create-null_SRC = tests/userprog/create-null.c tests/main.c
tests/userprog/create-bad-ptr_SRC = tests/userprog/create-bad-ptr.c	\
tests/main.c
tests/userprog/create-long_SRC = tests/userprog/create-long.c tests/main.c
tests/userprog/create-exists_SRC = tests/userprog/create-exists.c tests/main.c
tests/userprog/create-bound_SRC = tests/userprog/create-bound.c	\
tests/userprog/boundary.c tests/main.c
tests/userprog/open-normal_SRC = tests/userprog/open-normal.c tests/main.c
tests/userprog/open-missing_SRC = tests/userprog/open-missing.c tests/main.c
tests/userprog/open-boundary_SRC = tests/userprog/open-boundary.c	\
tests/userprog/boundary.c tests/main.c
tests/userprog/open-empty_SRC = tests/userprog/open-empty.c tests/main.c
tests/userprog/open-null_SRC = tests/userprog/open-null.c tests/main.c
tests/userprog/open-bad-ptr_SRC = tests/userprog/open-bad-ptr.c tests/main.c
tests/userprog/open-twice_SRC = tests/userprog/open-twice.c tests/main.c
tests/userprog/close-normal_SRC = tests/userprog/close-normal.c tests/main.c
tests/userprog/close-twice_SRC = tests/userprog/close-twice.c tests/main.c
tests/userprog/close-stdin_SRC = tests/userprog/close-stdin.c tests/main.c
tests/userprog/close-stdout_SRC = tests/userprog/close-stdout.c tests/main.c
tests/userprog/close-bad-fd_SRC = tests/userprog/close-bad-fd.c tests/main.c
tests/userprog/read-normal_SRC = tests/userprog/read-normal.c tests/main.c
tests/userprog/read-bad-ptr_SRC = tests/userprog/read-bad-ptr.c tests/main.c
tests/userprog/read-bad-buf_SRC = tests/userprog/read-bad-buf.c tests/main.c
tests/userprog/read-boundary_SRC = tests/userprog/read-boundary.c	\
tests/userprog/boundary.c tests/main.c
tests/userprog/read-zero_SRC = tests/userprog/read-zero.c tests/main.c
tests/userprog/read-stdout_SRC = tests/userprog/read-stdout.c tests/main.c
tests/userprog/read-bad-fd_SRC = tests/userprog/read-bad-fd.c tests/main.c
tests/userprog/write-normal_SRC = tests/userprog/write-normal.c tests/main.c
tests/userprog/write-bad-ptr_SRC = tests/userprog/write-bad-ptr.c tests/main.c
tests/userprog/write-bad-buf_SRC = tests/userprog/write-bad-buf.c tests/main.c
tests/userprog/write-boundary_SRC = tests/userprog/write-boundary.c	\
tests/userprog/boundary.c tests/main.c
tests/userprog/write-zero_SRC = tests/userprog/write-zero.c tests/main.c
tests/userprog/write-stdin_SRC = tests/userprog/write-stdin.c tests/main.c
tests/userprog/write-bad-fd_SRC = tests/userprog/write-bad-fd.c tests/main.c
tests/userprog/exec-once_SRC = tests/userprog/exec-once.c tests/main.c
tests/userprog/exec-arg_SRC = tests/userprog/exec-arg.c tests/main.c
tests/userprog/exec-large-arg_SRC = tests/userprog/exec-large-arg.c tests/main.c
tests/userprog/exec-multiple_SRC = tests/userprog/exec-multiple.c tests/main.c
tests/userprog/exec-missing_SRC = tests/userprog/exec-missing.c tests/main.c
tests/userprog/exec-over-arg_SRC = tests/userprog/exec-over-arg.c tests/main.c
tests/userprog/exec-over-args_SRC = tests/userprog/exec-over-args.c tests/main.c
tests/userprog/exec-bad-ptr_SRC = tests/userprog/exec-bad-ptr.c tests/main.c
tests/userprog/wait-simple_SRC = tests/userprog/wait-simple.c tests/main.c
tests/userprog/wait-twice_SRC = tests/userprog/wait-twice.c tests/main.c
tests/userprog/wait-killed_SRC = tests/userprog/wait-killed.c tests/main.c
tests/userprog/wait-load-kill_SRC = tests/userprog/wait-load-kill.c tests/main.c
tests/userprog/wait-bad-pid_SRC = tests/userprog/wait-bad-pid.c tests/main.c
tests/userprog/wait-bad-child_SRC = tests/userprog/wait-bad-child.c tests/main.c
tests/userprog/multi-recurse_SRC = tests/userprog/multi-recurse.c
tests/userprog/multi-child-fd_SRC = tests/userprog/multi-child-fd.c	\
tests/main.c
tests/userprog/rox-simple_SRC = tests/userprog/rox-simple.c tests/main.c
tests/userprog/rox-child_SRC = tests/userprog/rox-child.c tests/main.c
tests/userprog/rox-multichild_SRC = tests/userprog/rox-multichild.c	\
tests/main.c

tests/userprog/child-simple_SRC = tests/userprog/child-simple.c
tests/userprog/child-args_SRC = tests/userprog/args.c
tests/userprog/child-bad_SRC = tests/userprog/child-bad.c tests/main.c
tests/userprog/child-close_SRC = tests/userprog/child-close.c
tests/userprog/child-rox_SRC = tests/userprog/child-rox.c
tests/userprog/exec-exit_SRC = tests/userprog/exec-exit.c

$(foreach prog,$(tests/userprog_PROGS),$(eval $(prog)_SRC += tests/lib.c))

tests/userprog/args-single_ARGS = onearg
tests/userprog/args-multiple_ARGS = some arguments for you!
tests/userprog/args-many_ARGS = a b c d e f g h i j k l m n o p q r s t u v
tests/userprog/args-dbl-space_ARGS = two  spaces!
tests/userprog/multi-recurse_ARGS = 15

tests/userprog/open-normal_PUTFILES += tests/userprog/sample.txt
tests/userprog/open-boundary_PUTFILES += tests/userprog/sample.txt
tests/userprog/open-twice_PUTFILES += tests/userprog/sample.txt
tests/userprog/close-normal_PUTFILES += tests/userprog/sample.txt
tests/userprog/close-twice_PUTFILES += tests/userprog/sample.txt
tests/userprog/read-normal_PUTFILES += tests/userprog/sample.txt
tests/userprog/read-bad-ptr_PUTFILES += tests/userprog/sample.txt
tests/userprog/read-bad-buf_PUTFILES += tests/userprog/sample.txt
tests/userprog/read-boundary_PUTFILES += tests/userprog/sample.txt
tests/userprog/read-zero_PUTFILES += tests/userprog/sample.txt
tests/userprog/write-normal_PUTFILES += tests/userprog/sample.txt
tests/userprog/write-bad-ptr_PUTFILES += tests/userprog/sample.txt
tests/userprog/write-bad-buf_PUTFILES += tests/userprog/sample.txt
tests/userprog/write-boundary_PUTFILES += tests/userprog/sample.txt
tests/userprog/write-zero_PUTFILES += tests/userprog/sample.txt
tests/userprog/multi-child-fd_PUTFILES += tests/userprog/sample.txt

tests/userprog/exec-once_PUTFILES += tests/userprog/child-simple
tests/userprog/exec-multiple_PUTFILES += tests/userprog/child-simple
tests/userprog/wait-simple_PUTFILES += tests/userprog/child-simple
tests/userprog/wait-twice_PUTFILES += tests/userprog/child-simple

tests/userprog/exec-arg_PUTFILES += tests/userprog/child-args
tests/userprog/exec-large-arg_PUTFILES += tests/userprog/child-args
tests/userprog/exec-over-arg_PUTFILES += tests/userprog/child-args
tests/userprog/exec-over-args_PUTFILES += tests/userprog/child-args
tests/userprog/multi-child-fd_PUTFILES += tests/userprog/child-close
tests/userprog/wait-killed_PUTFILES += tests/userprog/child-bad
tests/userprog/wait-load-kill_PUTFILES += tests/userprog/child-bad
tests/userprog/wait-bad-child_PUTFILES += tests/userprog/exec-exit
tests/userprog/wait-bad-child_PUTFILES += tests/userprog/child-simple
tests/userprog/rox-child_PUTFILES += tests/userprog/child-rox
tests/userprog/rox-multichild_PUTFILES += tests/userprog/child-rox
