From bd8145e10a401506f33104ff9ef0bfffc373e8f4 Mon Sep 17 00:00:00 2001 From: Tejasvi Kashi Date: Tue, 29 Mar 2022 19:24:21 -0400 Subject: [PATCH] Added widefork and hogparty-many --- ASST3/1mb.conf | 135 +++++++++++++++++++++++++++ ASST3/basic/hogparty-many | 1 + ASST3/basic/widefork | 1 + ASST3/run.sh | 9 ++ ASST3/verify.py | 192 +++++++++++++++++++++++++++++++++++++- 5 files changed, 334 insertions(+), 4 deletions(-) create mode 100644 ASST3/1mb.conf create mode 100644 ASST3/basic/hogparty-many create mode 100644 ASST3/basic/widefork diff --git a/ASST3/1mb.conf b/ASST3/1mb.conf new file mode 100644 index 0000000..924a109 --- /dev/null +++ b/ASST3/1mb.conf @@ -0,0 +1,135 @@ +# Sample sys161.conf file +# +# This file tells System/161 what devices to use. +# +# There are 32 LAMEbus slots on the System/161 motherboard. There may +# be only one bus controller card, and it must go in slot 31. Other +# than that, you can put in whatever devices you want. +# +# The syntax is simple: one slot per line; the slot number goes first, +# then the expansion card name, then any arguments. Some of the devices +# have required arguments. +# +# The devices are: +# +# mainboard The multiprocessor LAMEbus controller card. Must go in +# slot 31, and only in slot 31. Required argument +# "ramsize=NUMBER" specifies the amount of physical RAM in +# the system. This amount must be a multiple of the +# hardware page size (which is probably 4096 or 8192.) The +# maximum amount of RAM allowed is 16M; this restriction +# is meant as a sanity check and can be altered by +# recompiling System/161. The argument "cpus=NUMBER" +# selects the number of CPUs; the default is 1 and the +# maximum 32. +# +# oldmainboard The uniprocessor LAMEbus controller card, fully +# backwards compatible with OS/161 1.x. In general, +# uniprocessor kernels should nonetheless work on the +# multiprocessor mainboard; therefore this device will +# probably be removed in the future. Configuration is the +# same as the multiprocessor mainboard, except that the +# "cpus" argument is not accepted. The OS/161 1.x name +# "busctl" is an alias for "oldmainboard". +# +# trace The System/161 trace controller device. This can be used +# by software for various debugging purposes. You can have +# more than one trace card, but they all manipulate the +# same internal state. No arguments. +# +# timer Countdown timer. The timer card also contains a real-time +# clock and a small speaker for beeping. Most configurations +# will include at least one timer. No arguments. +# +# serial Serial port. This is connected to the standard input and +# standard output of the System/161 process, and serves as +# the system console. Most configurations need this. There +# is no support at present for more than one serial port. +# No arguments. +# +# screen Full-screen memory-mapped text video card. This is +# connected to the standard input and standard output of +# the System/161 process, and serves as the system console. +# There is no support at present for more than one screen. +# Likewise, at present you may not use "screen" and "serial" +# together. No arguments. NOTE: not presently implemented. +# +# random (Pseudo-)random number generator. This accesses the +# randomizer state within System/161; thus, while you can +# add multiple random cards, they all return values from the +# same pseudorandom sequence. The random seed is set by +# using either the "seed=NUMBER" argument, which sets the +# random seed to a specified value, or the "autoseed" +# argument, which sets the random seed based on the host +# system clock. If neither argument is given or no random +# device is used, the seed is set to 0. Note that the seed +# affects various randomized behavior of the system as well +# as the values provided by the random device. +# +# disk Fixed disk. The options are as follows: +# rpm=NUMBER Set spin rate of disk. +# sectors=NUMBER Set disk size. Each sector is 512 bytes. +# file=PATH Specify file to use as storage for disk. +# paranoid Set paranoid mode. +# +# The "file=PATH" argument must be supplied. The size must be +# at least 128 sectors (64k), and the RPM setting must be a +# multiple of 60. +# +# The "paranoid" argument, if given, causes fsync() to be +# called on every disk write to make sure the data written +# reaches actual stable storage. This will make things very +# slow. +# +# You can have as many disks as you want (until you run out +# of slots) but each should have a distinct file to use for +# storage. Most common setups will use two separate disks, +# one for filesystem storage and one for swapping. +# +# nic Network card. This allows communication among multiple +# simultaneously-running copies of System/161. The arguments +# are: +# hub=PATH Give the path to the hub socket. +# hwaddr=NUMBER Specify the hardware-level card address. +# +# The hub socket path should be the argument supplied to the +# hub161 program. The default is ".sockets/hub". +# +# The hardware address should be unique among the systems +# connected to the same hub. It should be an integer between +# 1 and 65534. Values 0 and 65535 are reserved for special +# purposes. This argument is required. +# +# NOTE: disable (comment out) nic devices if you aren't +# actively using them, to avoid unnecessary overhead. +# +# emufs Emulator filesystem. This provides access *within* +# System/161 to the filesystem that System/161 is running +# in. There is one optional argument, "dir=PATH". The path +# specified is used as the root of the filesystem provided +# by emufs. (Note that it is possible to access the real +# parent of this root and thus any other directory; this +# argument does not restrict access.) The default path is +# ".", meaning System/161's own current directory. +# + +# +# Here is a suggested default configuration: 512k RAM, two 5M disks. +# + +0 serial +#0 screen + +1 emufs + +2 disk rpm=7200 sectors=10240 file=DISK1.img +3 disk rpm=7200 sectors=10240 file=DISK2.img + +#27 nic hwaddr=1 + +28 random autoseed +29 timer +30 trace +31 mainboard ramsize=1048576 cpus=1 +#31 mainboard ramsize=524288 cpus=2 +#31 mainboard ramsize=524288 cpus=4 diff --git a/ASST3/basic/hogparty-many b/ASST3/basic/hogparty-many new file mode 100644 index 0000000..02e803f --- /dev/null +++ b/ASST3/basic/hogparty-many @@ -0,0 +1 @@ +p uw-testbin/hogparty;p uw-testbin/hogparty;p uw-testbin/hogparty;p uw-testbin/hogparty;p uw-testbin/hogparty;q diff --git a/ASST3/basic/widefork b/ASST3/basic/widefork new file mode 100644 index 0000000..06cf06a --- /dev/null +++ b/ASST3/basic/widefork @@ -0,0 +1 @@ +p uw-testbin/widefork;p uw-testbin/widefork;p uw-testbin/widefork;p uw-testbin/widefork;p uw-testbin/widefork;q diff --git a/ASST3/run.sh b/ASST3/run.sh index b2f5245..4baf96c 100755 --- a/ASST3/run.sh +++ b/ASST3/run.sh @@ -27,6 +27,15 @@ for c in $ASSIGNMENTDIR/custom_*.conf do for f in $ASSIGNMENTDIR/basic/* do + if [ $f == "/assignments/ASST3//basic/widefork" ] || [ $f == "/assignments/ASST3//basic/hogparty-many" ]; + then + c="/assignments/ASST3/1mb.conf" + else + c="/assignments/ASST3/custom_0.conf" + fi + + echo "test: "$f" conf: "$c + echo ">SPLIT<" >> $LOG cname=$(basename -s .conf $c) fname=$(basename $f) diff --git a/ASST3/verify.py b/ASST3/verify.py index f093a37..653720c 100644 --- a/ASST3/verify.py +++ b/ASST3/verify.py @@ -129,7 +129,7 @@ def argtesttest(tests, helpers): def hogparty(tests, helpers): grade = 0 cmts = set() - mytests = [t for t in tests if "hogparty" in t.name] + mytests = [t for t in tests if "hogparty_custom_0" in t.name] for test in mytests: try: res = test.results().split('\n') @@ -139,8 +139,6 @@ def hogparty(tests, helpers): cmts.add("The output of hogparty is empty.") elif "Operation took" in res[i+4]: - operation_took_index = i + 4 - op_strs = res[i + 1] + res[i + 2] + res[i + 3] if op_strs.count('x') == 5 and op_strs.count('y') == 5 and op_strs.count('z') == 5: @@ -155,6 +153,190 @@ def hogparty(tests, helpers): return ("Test hogparty", grade, ",".join(cmts)) +def hogparty_many(tests, helpers): + grade = 0 + cmts = set() + mytests = [t for t in tests if "hogparty-many_1mb" in t.name] + success_count = 0 + for test in mytests: + try: + res = test.results().split('\n') + + i = 0 + indices = [] + + for result in res: + if "OS/161 kernel: p uw-testbin/hogparty" == result: + indices.append(i) + i+=1 + + for index in indices: + if "Operation took" in res[index+1]: + cmts.add("The output of hogparty-many is empty.") + + elif "Operation took" in res[index+4]: + op_strs = res[index + 1] + res[index + 2] + res[index + 3] + + if op_strs.count('x') == 5 and op_strs.count('y') == 5 and op_strs.count('z') == 5: + success_count+=1 + + if success_count == 5: + grade += 3 + else: + grade += 0 + + except Exception as e: + traceback.print_exc() + cmts.add("Cannot parse assignment log - likely an error in your assignment") + + if grade == 0: + cmts.add("The output of hogparty-many is too long or incorrect. Ran only {0}/5 times".format(success_count)) + + return ("Test hogparty-many", grade, ",".join(cmts)) + +def widefork(tests, helpers): + grade = 0 + cmts = set() + mytests = [t for t in tests if "widefork" in t.name] + success_count = 0 + + for test in mytests: + try: + res = test.results().split('\n') + i = 0 + indices = [] + + for result in res: + if "OS/161 kernel: p uw-testbin/widefork" == result: + indices.append(i) + i+=1 + + for index in indices: + if "Operation took" in res[index+1]: + cmts.add("The output of widefork is empty.") + + j = 1 + s = [] + + while not "Operation took" in res[index+j]: + for c in res[index+j].strip(): + s.append(c) + j = j + 1 + + P_num = 0 + A_num = 0 + B_num = 0 + C_num = 0 + a_num = 0 + b_num = 0 + c_num = 0 + x_num = 0 + error = False + + for c in s: + if c == 'P': + P_num = P_num + 1 + if P_num > 3: + error = True + cmts.add("Too many P") + break + elif c == 'A': + if P_num == 0: + error = True + cmts.add("A must be preceded by one P") + break + elif A_num == 1: + error = True + cmts.add("There should be one A only.") + break + else: + P_num -= 1 + A_num = 1 + elif c == 'B': + if P_num == 0: + error = True + cmts.add("B found but not enough P's (should be at LEAST 2)") + break + elif B_num == 1: + error = True + cmts.add("There should be one B only.") + break + else: + B_num = 1 + P_num -= 1 + elif c == 'C': + if P_num == 0: + error = True + cmts.add("C found but not enough P's (should be at LEAST 3)") + break + elif C_num == 1: + error = True + cmts.add("There should be one C only.") + break + else: + C_num = 1 + P_num -= 1 + elif c == 'a': + if A_num != 1: + error = True + cmts.add("a must be preceded by A") + break + elif a_num != 0: + error = True + cmts.add("There should be one a only.") + break + else: + a_num = 1 + elif c == 'b': + if B_num != 1: + error = True + cmts.add("b must be preceded by B") + break + elif b_num != 0: + error = True + cmts.add("There should be one b only.") + break + else: + b_num = 1 + elif c == 'c': + if C_num != 1: + error = True + cmts.add("c must be preceded by C") + break + elif c_num != 0: + error = True + cmts.add("There should be one c only.") + break + else: + c_num = 1 + elif c == 'x': + x_num = x_num + 1 + else: + error = True + cmts.add("Wrong output: {}".format(c)) + break + + if error: + cmts.add("Incorrect output: {}".format("".join(s))) + elif a_num == 1 and b_num == 1 and c_num == 1 and len(s) == 9: + success_count+=1 + else: + cmts.add("Incorrect output: {}".format("".join(s))) + + if success_count == 5: + grade += 2 + else: + grade += 0 + + except Exception as e: + traceback.print_exc() + cmts.add("Cannot parse assignment log - likely an error in your assignment") + + if grade == 0: + cmts.add("The output of widefork is too long or incorrect. Ran {0}/5 times".format(success_count)) + + return ("Test widefork", grade, ",".join(cmts)) + def romemwrite(tests, helpers): grade = 0 cmts = set() @@ -452,6 +634,7 @@ RUBRIC = { argtest_none: 2, argtesttest: 4, hogparty: 9, + hogparty_many: 3, matmult: 8, romemwrite: 8, sort: 8, @@ -459,5 +642,6 @@ RUBRIC = { vm_crash2: 8, vm_data1: 2, vm_data1_many: 8, - vm_data3: 3 + vm_data3: 3, + widefork: 2 } -- GitLab