diff --git a/Makefile b/Makefile index 797d6f6..338d79b 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ LABS=" lab1 lab2a lab2b lab2c lab2d lab3a lab3b lab4a lab4b " "--exclude=src/main/mr-*" \ "--exclude=mrtmp.*" \ "--exclude=src/main/diff.out" \ - "--exclude=src/main/mrmaster" \ + "--exclude=src/main/mrcoordinator" \ "--exclude=src/main/mrsequential" \ "--exclude=src/main/mrworker" \ "--exclude=*.so" \ diff --git a/src/kvraft/test_test.go b/src/kvraft/test_test.go index 162eb7e..df34365 100644 --- a/src/kvraft/test_test.go +++ b/src/kvraft/test_test.go @@ -37,11 +37,17 @@ func (log *OpLog) Read() []porcupine.Operation { return ops } +// to make sure timestamps use the monotonic clock, instead of computing +// absolute timestamps with `time.Now().UnixNano()` (which uses the wall +// clock), we measure time relative to `t0` using `time.Since(t0)`, which uses +// the monotonic clock +var t0 = time.Now() + // get/put/putappend that keep counts func Get(cfg *config, ck *Clerk, key string, log *OpLog, cli int) string { - start := time.Now().UnixNano() + start := int64(time.Since(t0)) v := ck.Get(key) - end := time.Now().UnixNano() + end := int64(time.Since(t0)) cfg.op() if log != nil { log.Append(porcupine.Operation{ @@ -57,9 +63,9 @@ func Get(cfg *config, ck *Clerk, key string, log *OpLog, cli int) string { } func Put(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) { - start := time.Now().UnixNano() + start := int64(time.Since(t0)) ck.Put(key, value) - end := time.Now().UnixNano() + end := int64(time.Since(t0)) cfg.op() if log != nil { log.Append(porcupine.Operation{ @@ -73,9 +79,9 @@ func Put(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) } func Append(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) { - start := time.Now().UnixNano() + start := int64(time.Since(t0)) ck.Append(key, value) - end := time.Now().UnixNano() + end := int64(time.Since(t0)) cfg.op() if log != nil { log.Append(porcupine.Operation{ diff --git a/src/main/test-mr.sh b/src/main/test-mr.sh index 6e87891..1adc9d8 100644 --- a/src/main/test-mr.sh +++ b/src/main/test-mr.sh @@ -7,7 +7,7 @@ # comment this out to run the tests without the Go race detector. RACE=-race -if [ "$OSTYPE" = "darwin" ] +if [[ "$OSTYPE" = "darwin"* ]] then if go version | grep 'go1.17.[012345]' then @@ -30,7 +30,7 @@ else else # no timeout command TIMEOUT= - echo '*** Cannot find timeout command; proceeding anyway.' + echo '*** Cannot find timeout command; proceeding without timeouts.' fi fi if [ "$TIMEOUT" != "" ] @@ -233,7 +233,7 @@ sleep 1 # `jobs` ensures that any completed old processes from other tests # are not waited upon. jobs &> /dev/null -if [ "$OSTYPE" = "darwin" ] +if [[ "$OSTYPE" = "darwin"* ]] then # bash on the Mac doesn't have wait -n while [ ! -e $DF ]