def test_multiple_dirs_3(): sandbox = Sandbox("test_multiple_dirs_3", "{}".format(" ".join(["mydir" + str(n) for n in range(1, 8)]))) sandbox.cmd("mkdir {} && touch {}".format( " ".join(["mydir" + str(n) for n in range(1, 8)]), " ".join(["mydir" + str(n) + "/file" + str(n2) for n2 in range(1, 12) for n in range(1, 8)]) )) return sandbox.run()
def test_R_flag_1(): sandbox = Sandbox("test_R_flag_1", "-R") sandbox.cmd("mkdir -p {}".format(" ".join([ "level1_" + str(n) + "/level2_" + str(n2) + "/level3_" + str(n3) for n3 in range(1, 3) for n2 in range(1, 3) for n in range(1, 3) ]))) return sandbox.run()
def test_multiple_dirs_2(): sandbox = Sandbox("test_multiple_dirs_2", "mydir mydir2") sandbox.cmd("mkdir mydir mydir2 && touch {} && touch {}".format( " ".join(["mydir/file" + str(n) for n in range(10, 21)]), " ".join(["mydir2/file" + str(n) for n in range(30, 41)]), )) return sandbox.run()
def test_rR_flag_3(): sandbox = Sandbox("test_rR_flag_3", "-rR") sandbox.cmd("mkdir -p {}".format(" ".join([ "level_1" + str(n) + "/level2_" + str(n2) + "/level3_" + str(n3) for n3 in range(11, 14) for n2 in range(6, 9) for n in range(1, 4) ]))) return sandbox.run()
def test_t_flag_7(): sandbox = Sandbox("test_t_flag_7", "-t") sandbox.cmd( "touch C && touch -t 201212101830.55 c && mkdir -p sbox sbox1 && " "touch -t 201312101830.55 B && " "touch -t 201312101830.55 a") return sandbox.run()
def test_l_flag_1(): sandbox = Sandbox("test_l_flag_1", "-l") sandbox.cmd("touch a b c && echo 'coucou' > a && echo 'hello world' > b") sandbox.cmd( "mkdir 111 222 333 444 && touch 111/{a,b,c} && echo 'eat pizza' > 111/a" ) return sandbox.run()
def test_perms_2(): sandbox = Sandbox("test_perms_2", "-l") sandbox.cmd("mkdir a b c") sandbox.cmd("chmod 644 a") sandbox.cmd("chmod 755 b") sandbox.cmd("chmod 311 c") return sandbox.run()
def test_perms_1(): sandbox = Sandbox("test_perms_1", "-l") sandbox.cmd("touch a b c") sandbox.cmd("chmod 644 a") sandbox.cmd("chmod 755 b") sandbox.cmd("chmod 311 c") return sandbox.run()
def test_a_flag_2(): sandbox = Sandbox("test_a_flag_2", "-a") sandbox.cmd("mkdir {} {} && touch {} {}".format( " ".join([".hiddendir" + str(n) for n in range(1, 11)]), " ".join(["dir" + str(n) for n in range(1, 11)]), " ".join([".hiddenfile" + str(n) for n in range(1, 11)]), " ".join(["file" + str(n) for n in range(1, 11)]))) return sandbox.run()
def test_t_flag_6(): sandbox = Sandbox("test_t_flag_6", "-t") sandbox.cmd("mkdir -p {}".format(" ".join([ "level1_" + str(n) + "/level2_" + str(n2) for n2 in range(1, 3) for n in range(1, 3) ]))) sandbox.cmd("touch -t 201312101830.55 B && " "touch -t 201312101830.55 a") return sandbox.run()
def test_t_flag_5(): sandbox = Sandbox("test_t_flag_5", "-t") sandbox.cmd("touch -t 200012101830.55 a && " "touch -t 201412101830.55 b && " "ln b d && " "ln -s c e && " "ln -s a f && " "touch -t 300012101830.55 c") return sandbox.run()
def test_t_flag_3(): sandbox = Sandbox("test_t_flag_3", "-t") sandbox.cmd("touch {} {} {} && touch -t 200012101830.55 {}".format( " ".join(["fileA" + str(n) for n in range(1, 6)]), " ".join(["fileB" + str(n) for n in range(1, 6)]), " ".join(["fileC" + str(n) for n in range(1, 6)]), " ".join(["fileA" + str(n) for n in range(1, 6)]), )) return sandbox.run()
def test_multiple_dirs_1(): sandbox = Sandbox("test_multiple_dirs_1", "mydir mydir2") sandbox.cmd("mkdir mydir mydir2") sandbox.cmd("touch mydir/aaa") sandbox.cmd("touch mydir/bbb") sandbox.cmd("touch mydir/ccc") sandbox.cmd("touch mydir2/111") sandbox.cmd("touch mydir2/222") sandbox.cmd("touch mydir2/333") return sandbox.run()
def test_t_flag_4(): sandbox = Sandbox("test_t_flag_4", "-t") sandbox.cmd("touch -t 201312101830.55 a && " "touch -t 201212101830.55 b && " "touch -t 201412101830.55 c && " "touch -t 201411221830.55 d && " "touch -t 201405212033.55 e && " "touch -t 201409221830.55 f && " "touch -t 202007221830.55 g && " "touch -t 300012101830.55 h") return sandbox.run()
def test_error_handling_13(): sandbox = Sandbox( "test_error_handling_13", "adir zdir aNotExist zNotExistB afile zfile asymdir zsymdir asymfile zsymfile" ) sandbox.cmd("mkdir adir zdir") sandbox.cmd("touch afile zfile") sandbox.cmd("ln -s adir asymdir") sandbox.cmd("ln -s adir zsymdir") sandbox.cmd("ln -s afile asymfile") sandbox.cmd("ln -s afile zsymfile") return sandbox.run()
def test_flags_mix_1(): sandbox = Sandbox("test_flags_mix_1", "-lR .") sandbox.cmd("mkdir {} {}".format( " ".join(["dir" + str(n) for n in range(1, 5)]), " ".join([".hdir" + str(n) for n in range(1, 5)]))) sandbox.cmd("touch {} {}".format( " ".join(["dir1/file" + str(n) for n in range(1, 5)]), " ".join(["dir1/.hfile" + str(n) for n in range(1, 5)]))) sandbox.cmd("touch {} {}".format( " ".join([".hdir1/file" + str(n) for n in range(1, 5)]), " ".join([".hdir1/.hfile" + str(n) for n in range(1, 5)]))) sandbox.cmd("touch a && ln -s a symlink") return sandbox.run()
def test_tR_flag_1(): sandbox = Sandbox("test_tR_flag_1", "-tR") sandbox.cmd( "mkdir -p {} && " "mkdir -p {} && " "mkdir -p sbox/level1_1 sbox/level1_1/level2_1 && " "touch -t 201212101830.55 sbox/c_lvl1 && " "touch -t 201212101830.55 sbox/level1_1/c_lvl2 && " "touch -t 201212101830.55 sbox/level1_1/level2_1/c_lvl3".format( " ".join([ "sbox/level1_" + str(n) + "/level2_" + str(n2) + "/level3_" + str(n3) for n3 in range(1, 3) for n2 in range(1, 3) for n in range(1, 3) ]), " ".join([ "sbox1/level1_" + str(n) + "/level2_" + str(n2) + "/level3_" + str(n3) for n3 in range(1, 3) for n2 in range(1, 3) for n in range(1, 3) ]), )) return sandbox.run()
def test_R_flag_7(): sandbox = Sandbox("test_R_flag_7", "-R A a rootfile rootfile") sandbox.cmd("mkdir A") sandbox.cmd("touch A/file rootfile") return sandbox.run()
def test_R_flag_6(): sandbox = Sandbox("test_R_flag_6", "-R A a") sandbox.cmd("mkdir A") sandbox.cmd("touch A/file") return sandbox.run()
def test_R_flag_5(): sandbox = Sandbox("test_R_flag_5", "-R") sandbox.cmd("mkdir a b c") sandbox.cmd("chmod 000 b") return sandbox.run()
def test_R_flag_3(): sandbox = Sandbox("test_R_flag_3", "-R") sandbox.cmd("mkdir -p .a .b .c && mkdir -p a b c ") return sandbox.run()
def test_hyphen_harder_2(): sandbox = Sandbox("test_hyphen_harder_2", "- - -") sandbox.cmd("") return sandbox.run()
def test_hyphen_harder_6(): sandbox = Sandbox("test_hyphen_harder_6", "-- -- --") sandbox.cmd("mkdir -- - -- ---") return sandbox.run()
def test_hyphen_harder_1(): sandbox = Sandbox("test_hyphen_harder_1", "-- -- --") sandbox.cmd("touch -- - -- --") return sandbox.run()
def test_special_bits_16(): sandbox = Sandbox("test_special_bits_16", "-l") sandbox.cmd("touch file16 && chmod 7000 file16") return sandbox.run()
def test_special_bits_2(): sandbox = Sandbox("test_special_bits_2", "-l") sandbox.cmd("touch file2 && chmod 1777 file2") return sandbox.run()
def test_special_bits_15(): sandbox = Sandbox("test_special_bits_15", "-l") sandbox.cmd("touch file15 && chmod 6000 file15") return sandbox.run()
def test_special_bits_14(): sandbox = Sandbox("test_special_bits_14", "-l") sandbox.cmd("touch file14 && chmod 5000 file14") return sandbox.run()
def test_special_bits_13(): sandbox = Sandbox("test_special_bits_13", "-l") sandbox.cmd("touch file13 && chmod 4000 file13") return sandbox.run()
def test_special_bits_12(): sandbox = Sandbox("test_special_bits_12", "-l") sandbox.cmd("touch file12 && chmod 3000 file12") return sandbox.run()