コード例 #1
0
ファイル: test14.py プロジェクト: dshi7/537-sp14
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)
    util.info("")
    util.info("- Sending ./testclient localhost 2010 /testdata/file1.txt")

    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")
    arrival = util.get_stat2(res, "Stat-req-arrival")
    dispatch = util.get_stat2(res, "Stat-req-dispatch")
    read = util.get_stat2(res, "Stat-req-read")
    complete = util.get_stat2(res, "Stat-req-complete")
    print ""
    print "dispatch = " + str(dispatch)
    print "read = " + str(read)
    print "complete = " + str(complete)


    if dispatch >= 0 and read >=0 and complete >= 0 and dispatch + read <= complete:
        util.good("You passed this test")
    else:
        util.error("Expected dispatch >= 0 and read >=0 and complete >= 0 and" 
                   " dispatch + read <= complete:")
コード例 #2
0
ファイル: test18.py プロジェクト: yangsuli/oscourseprojects
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)
    util.info("")
    util.info("- Sending ./testclient localhost 2010 /testdata/file1.txt")

    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")
    arrival = util.get_stat2(res, "Stat-req-arrival")
    dispatch = util.get_stat2(res, "Stat-req-dispatch")
    read = util.get_stat2(res, "Stat-req-read")
    complete = util.get_stat2(res, "Stat-req-complete")
    print ""
    print "dispatch = " + str(dispatch)
    print "read = " + str(read)
    print "complete = " + str(complete)

    if dispatch >= 0 and read >= 0 and complete >= 0 and dispatch + read <= complete:
        util.good("You passed this test")
    else:
        util.error("Expected dispatch >= 0 and read >=0 and complete >= 0 and"
                   " dispatch + read <= complete:")
コード例 #3
0
def test(cmd):

    print "##########################################"
    print "# check arrival time"
    print "# IMPORTANT IMPORTANT: we expect the arrival time "
    print "# NOT NOT microseconds"
    print "# but IN MILIseconds"
    print "##########################################"

    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    res1 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res2 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res3 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res4 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")

    arr1 = util.get_stat2(res1, "Stat-req-arrival")
    arr2 = util.get_stat2(res2, "Stat-req-arrival")
    arr3 = util.get_stat2(res3, "Stat-req-arrival")
    arr4 = util.get_stat2(res4, "Stat-req-arrival")

    print "arrival 1 = " + str(arr1)
    print "arrival 2 = " + str(arr2)
    print "arrival 3 = " + str(arr3)
    print "arrival 4 = " + str(arr4)

    #    s = 1000000 # 1 second
    s = 1000  # IN MILIseconds, i.e 1 seconds

    passed = arr1 + s <= arr2
    passed = passed and arr2 + s <= arr3
    passed = passed and arr3 + s <= arr4

    if passed:
        util.good("Congrats! You passed the final test")
    else:
        util.error("Come on! this is the final one... go go go !")

    util.kill()
コード例 #4
0
ファイル: test20.py プロジェクト: yangsuli/oscourseprojects
def test(cmd):

    print "##########################################"
    print "# check arrival time"
    print "# IMPORTANT IMPORTANT: we expect the arrival time "
    print "# NOT NOT microseconds"
    print "# but IN MILIseconds"
    print "##########################################"
    
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)

    res1 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt");
    time.sleep(1)
    res2 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res3 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res4 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")

    arr1 = util.get_stat2(res1, "Stat-req-arrival")
    arr2 = util.get_stat2(res2, "Stat-req-arrival")
    arr3 = util.get_stat2(res3, "Stat-req-arrival")
    arr4 = util.get_stat2(res4, "Stat-req-arrival")
                          
    print "arrival 1 = " + str(arr1)
    print "arrival 2 = " + str(arr2)
    print "arrival 3 = " + str(arr3)
    print "arrival 4 = " + str(arr4)

#    s = 1000000 # 1 second
    s = 1000 # IN MILIseconds, i.e 1 seconds

    passed = arr1 + s <= arr2
    passed = passed and arr2 + s <= arr3
    passed = passed and arr3 + s <= arr4
    
    if passed:
        util.good("Congrats! You passed the final test")
    else:
        util.error("Come on! this is the final one... go go go !")

    util.kill()
コード例 #5
0
ファイル: test13.py プロジェクト: dshi7/537-sp14
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    count = util.get_stat2(res, "Stat-thread-count")
    static = util.get_stat2(res, "Stat-thread-static")
    dynamic = util.get_stat2(res, "Stat-thread-dynamic")

    print "count = " + str(count)
    print "static = " + str(static)
    print "dynamic = " + str(dynamic)

    # sanity check
    if count != static + dynamic:
        util.error("Expected: count = static + dynamic")

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if static == 1 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 1 and dynamic = 1")

    if cmd.find("FIFO") > 0:
        if static  == 3 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 3 and dynamic = 1")

    if cmd.find("SFF-BS") > 0:
        if static  == 2 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 2 and dynamic = 1")
    
    util.kill()
コード例 #6
0
ファイル: test17.py プロジェクト: yangsuli/oscourseprojects
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    count = util.get_stat2(res, "Stat-thread-count")
    static = util.get_stat2(res, "Stat-thread-static")
    dynamic = util.get_stat2(res, "Stat-thread-dynamic")

    print "count = " + str(count)
    print "static = " + str(static)
    print "dynamic = " + str(dynamic)

    # sanity check
    if count != static + dynamic:
        util.error("Expected: count = static + dynamic")

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if static == 1 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 1 and dynamic = 1")

    if cmd.find("FIFO") > 0:
        if static == 3 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 3 and dynamic = 1")

    if cmd.find("SFF-BS") > 0:
        if static == 2 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 2 and dynamic = 1")

    util.kill()
コード例 #7
0
ファイル: test19.py プロジェクト: yangsuli/oscourseprojects
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    age = util.get_stat2(res, "Stat-req-age")

    print "age = " + str(age)

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if age == 0:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 0")

    if cmd.find("FIFO") > 0:
        if age == 2:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 2")

    if cmd.find("SFF-BS") > 0:
        if age == 1:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 1")

    util.kill()
コード例 #8
0
ファイル: test19.py プロジェクト: yangsuli/oscourseprojects
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    age = util.get_stat2(res, "Stat-req-age")

    print "age = " + str(age)

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if age == 0:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 0")

    if cmd.find("FIFO") > 0:
        if age == 2:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 2")

    if cmd.find("SFF-BS") > 0:
        if age == 1:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 1")

    util.kill()