資源簡介
《MIT JOS Lab1: Booting a PC》實驗代碼,這是2019.9.10日為止最全的代碼,滿分版本,當然,我也查過了許多資料,再次做了資料整合以及一些我自己的理解。希望能使大家受益。

代碼片段和文件信息
from?__future__?import?print_function
import?sys?os?re?time?socket?select?subprocess?errno?shutil?traceback
from?subprocess?import?check_call?Popen
from?optparse?import?OptionParser
__all__?=?[]
##################################################################
#?Test?structure
#
__all__?+=?[“test“?“end_part“?“run_tests“?“get_current_test“]
TESTS?=?[]
TOTAL?=?POSSIBLE?=?0
PART_TOTAL?=?PART_POSSIBLE?=?0
CURRENT_TEST?=?None
def?test(points?title=None?parent=None):
????“““Decorator?for?declaring?test?functions.??If?title?is?None?the
????title?of?the?test?will?be?derived?from?the?function?name?by
????stripping?the?leading?“test_“?and?replacing?underscores?with
????spaces.“““
????def?register_test(fn?title=title):
????????if?not?title:
????????????assert?fn.__name__.startswith(“test_“)
????????????title?=?fn.__name__[5:].replace(“_“?“?“)
????????if?parent:
????????????title?=?“??“?+?title
????????def?run_test():
????????????global?TOTAL?POSSIBLE?CURRENT_TEST
????????????#?Handle?test?dependencies
????????????if?run_test.complete:
????????????????return
????????????run_test.complete?=?True
????????????if?parent:
????????????????parent()
????????????#?Run?the?test
????????????fail?=?None
????????????start?=?time.time()
????????????CURRENT_TEST?=?run_test
????????????sys.stdout.write(“%s:?“?%?title)
????????????sys.stdout.flush()
????????????try:
????????????????fn()
????????????except?Assertionerror?as?e:
????????????????fail?=?““.join(traceback.format_exception_only(type(e)?e))
????????????#?Display?and?handle?test?result
????????????POSSIBLE?+=?points
????????????if?points:
????????????????print(“%s“?%?\
????????????????????(color(“red“?“FAIL“)?if?fail?else?color(“green“?“OK“))?end=‘?‘)
????????????if?time.time()?-?start?>?0.1:
????????????????print(“(%.1fs)“?%?(time.time()?-?start)?end=‘?‘)
????????????print()
????????????if?fail:
????????????????print(“????%s“?%?fail.replace(“\n“?“\n????“))
????????????else:
????????????????TOTAL?+=?points
????????????for?callback?in?run_test.on_finish:
????????????????callback(fail)
????????????CURRENT_TEST?=?None
????????#?Record?test?metadata?on?the?test?wrapper?function
????????run_test.__name__?=?fn.__name__
????????run_test.title?=?title
????????run_test.complete?=?False
????????run_test.on_finish?=?[]
????????TESTS.append(run_test)
????????return?run_test
????return?register_test
def?end_part(name):
????def?show_part():
????????global?PART_TOTAL?PART_POSSIBLE
????????print(“Part?%s?score:?%d/%d“?%?\
????????????(name?TOTAL?-?PART_TOTAL?POSSIBLE?-?PART_POSSIBLE))
????????print()
????????PART_TOTAL?PART_POSSIBLE?=?TOTAL?POSSIBLE
????show_part.title?=?““
????TESTS.append(show_part)
def?run_tests():
????“““Set?up?for?testing?and?run?the?registered?test?functions.“““
????#?Handle?command?line
????global?options
????parser?=?OptionParser(usage=“usage:?%prog?[-v]?[filters...]“)
????parser.add_option(“-v“?“--verbose“?action=“store_true“
??????????????????????help=“prin
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????214??2019-09-10?08:14??jos01\.dir-locals.el
?????文件????????859??2019-09-10?08:13??jos01\.gdbinit
?????文件????????857??2019-09-10?08:14??jos01\.gdbinit.tmpl
?????文件?????????20??2019-09-10?08:13??jos01\.git\COMMIT_EDITMSG
?????文件????????272??2019-09-10?08:14??jos01\.git\config
?????文件?????????73??2019-09-10?08:13??jos01\.git\desc
?????文件????????105??2019-09-10?08:13??jos01\.git\FETCH_HEAD
?????文件?????????23??2019-09-10?08:13??jos01\.git\HEAD
?????文件????????452??2019-09-10?08:13??jos01\.git\hooks\applypatch-msg.sample
?????文件????????896??2019-09-10?08:13??jos01\.git\hooks\commit-msg.sample
?????文件????????189??2019-09-10?08:13??jos01\.git\hooks\post-update.sample
?????文件????????398??2019-09-10?08:13??jos01\.git\hooks\pre-applypatch.sample
?????文件???????1704??2019-09-10?08:13??jos01\.git\hooks\pre-commit.sample
?????文件???????1348??2019-09-10?08:13??jos01\.git\hooks\pre-push.sample
?????文件???????4951??2019-09-10?08:13??jos01\.git\hooks\pre-reba
?????文件???????1239??2019-09-10?08:13??jos01\.git\hooks\prepare-commit-msg.sample
?????文件???????3611??2019-09-10?08:13??jos01\.git\hooks\update.sample
?????文件???????6363??2019-09-10?08:13??jos01\.git\index
?????文件????????240??2019-09-10?08:14??jos01\.git\info\exclude
?????文件????????678??2019-09-10?08:13??jos01\.git\logs\HEAD
?????文件????????678??2019-09-10?08:13??jos01\.git\logs\refs\heads\master
?????文件????????304??2019-09-10?08:13??jos01\.git\logs\refs\remotes\origin\master
?????文件????????285??2019-09-10?08:13??jos01\.git\ob
?????文件????????145??2019-09-10?08:13??jos01\.git\ob
?????文件????????829??2019-09-10?08:13??jos01\.git\ob
?????文件???????6000??2019-09-10?08:13??jos01\.git\ob
?????文件?????????55??2019-09-10?08:13??jos01\.git\ob
?????文件???????4177??2019-09-10?08:14??jos01\.git\ob
?????文件????????255??2019-09-10?08:13??jos01\.git\ob
?????文件???????3143??2019-09-10?08:13??jos01\.git\ob
............此處省略436個文件信息
- 上一篇:南昌大學匯編實驗報告
- 下一篇:ssd6系統級編程
評論
共有 條評論