contributed by < Jyun-Neng >
請補上實驗環境
課程助教
Makefile
make
指令後便不會產生 handin.tar
handin.tar
的存在是為了 CMU Autolab 使用,以我們的使用情境來說,的確多餘,歡迎送 pull request 過來
size
雖說若 q 是 NULL 則 free(q)
不會運作,
但 pos = q->head
在 q 是 NULL 的情況下會導致 segmantation fault。因此,仍需要判斷 q 是否為 NULL。
若 sp
不是 NULL,被移除的 element 內儲存的字串需複製到 sp
且要比較字串長度及bufsize
,若字串長度大於 bufsize-1
,僅複製 bufsize-1
的字串。反之,則複製整個字串大小,且最後都需加入 null character。
free 字串會出現 double free error 是 strdup 惹的禍,因為 harness.h 有段 macro 會把 free 換成一個自己開發的函式,導致你用不到真正的 free ,變成在用 malloc 與 test_free ,因此直接用 malloc 讓 preprocessor 把它也轉成 test_malloc 就好了。
pjchiou2018 Sep 27 Thu 05:58
分析測試的結果,剩餘的錯誤是因為尚未完成 reverse 所導致,其餘的部分皆已完成且通過測試。
未完成 reverse 的測試結果: 81/100
LawrenceSat, Sep 22, 2018 11:35 PM
Reverse 完成後發現 remove 是有問題的,string copy 沒有分辨好要複製的長度及沒有加 null character。
LawrenceSun, Sep 23, 2018 3:34 PM
修改完 copy string 的問題後測試完成: 100/100
LawrenceSun, Sep 23, 2018 3:36 PM
請繼續更新!
– 課程助教
driver.py
getopt
optlist, args = getopt.getopt(args, 'hp:t:v:A')
這段程式碼將所需的參數存到 optlist
sys.argv[1:]
. options is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon (:
; i.e., the same format that Unix getopt() uses).runTrace
runTrace
為執行測試指令的函式
retcode = subprocess.call(clist)
等同於執行 command line ./qtest -v -f ./traces/file.cmd
,qtest
便會執行 file.cmd
的指令來測試。
qtest.c
測試程式的指令是由 console.[ch]
來管理,且是用 linked list 來儲存新增的指令。