def test_one_with_flag2(sha1_orig, suffix, flag1, flag2): pigz_exe = os.path.join("..", "rel", "pigz.exe") unpigz_exe = os.path.join("..", "rel", "unpigz.exe") util.run_cmd_throw(pigz_exe, flag1, flag2, "pigz.c") util.run_cmd_throw(pigz_exe, "-t", "pigz.c" + suffix) util.run_cmd_throw(unpigz_exe, "pigz.c" + suffix) assert sha1_orig == util.file_sha1("pigz.c")
def copy_file(srcDir, dstDir, moveFiles, fileName, dstDir2): srcPath = pj(srcDir, fileName) sha = file_sha1(srcPath) ext = os.path.splitext(fileName)[1].lower() dstPath = pj(dstDir, dstDir2, sha + ext) print("Copying %s to %s" % (srcPath, dstPath)) if os.path.exists(dstPath): print(" %s already exists" % dstPath) else: shutil.copyfile(srcPath, dstPath) if moveFiles: print(" deleting %s" % srcPath) os.remove(srcPath) return sha
def test(): cd_to_pigz() util.create_dir("pigz_test_tmp") shutil.copyfile("pigz.c", os.path.join("pigz_test_tmp", "pigz.c")) os.chdir("pigz_test_tmp") sha1_orig = util.file_sha1("pigz.c") test_one_with_flag(sha1_orig, ".gz", "-f") test_one_with_flag2(sha1_orig, ".gz", "-fb", "32") test_one_with_flag2(sha1_orig, ".gz", "-fp", "1") test_one_with_flag(sha1_orig, ".zz", "-fz") test_one_with_flag(sha1_orig, ".zip", "-fK") test_one_with_flag2(sha1_orig, ".gz", "-11", "-f") # TODO: more tests for stdin/stdout # TODO: compare with gzip/compress (if available in path) cd_to_pigz() rm_dirs(["pigz_test_tmp"])