class TestCPIOFunctions(unittest.TestCase): TEST_DST_DIR = "/tmp/cpio_test_dir" TEST_SRC_DIR = "/" TEST_FILE_LIST_FILE = "/tmp/test_file_list" TEST_CONTENTS_LIST = [] TEST_DIR_LIST_FILE = "/tmp/test_dir_list" TEST_SKIP_FILE_LIST_FILE = "/tmp/test_skip_file_list" TEST_DIR_EXCL_LIST_FILE = "/tmp/test_dir_excl_list" TEST_MEDIA_TRANSFORM = "/tmp/media_transform" def setUp(self): InstallEngine._instance = None InstallEngine() self.engine = InstallEngine.get_instance() self.doc = self.engine.data_object_cache.volatile self.soft_node = Software("CPIO_Transfer", "CPIO") self.tr_node = CPIOSpec() self.soft_node.insert_children([self.tr_node]) self.doc.insert_children([self.soft_node]) self.tr_cpio = TransferCPIO("CPIO_Transfer") def tearDown(self): if os.access(self.TEST_DST_DIR, os.F_OK): shutil.rmtree(self.TEST_DST_DIR) if os.access(self.TEST_FILE_LIST_FILE, os.F_OK): os.unlink(self.TEST_FILE_LIST_FILE) if os.access(self.TEST_DIR_LIST_FILE, os.F_OK): os.unlink(self.TEST_DIR_LIST_FILE) if os.access(self.TEST_SKIP_FILE_LIST_FILE, os.F_OK): os.unlink(self.TEST_SKIP_FILE_LIST_FILE) if os.access(self.TEST_DST_DIR, os.F_OK): os.unlink(self.TEST_DST_DIR) if os.access(self.TEST_MEDIA_TRANSFORM, os.F_OK): os.unlink(self.TEST_MEDIA_TRANSFORM) if os.access("/tmp/media_not_exec", os.F_OK): os.unlink("/tmp/media_not_exec") self.engine.data_object_cache.clear() self.doc = None self.engine = None self.soft_node = None self.tr_node = None self.tr_cpio = None InstallEngine._instance = None TEST_CONTENTS_LIST = [] def test_software_type(self): self.assertTrue(self.soft_node.tran_type == "CPIO") def test_entire(self): '''Test transfer all of /etc/X11 to /rpool/cpio_test_dir succeeds''' # Set up the source src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cleanup_temp_files(self): '''Test the cleanup of the temporary files''' # Set up the source src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] self.tr_cpio._parse_input() try: self.tr_cpio._cleanup_tmp_files() except Exception as err: self.fail(str(err)) def test_cleanup_temp_files_nonexistent_file(self): '''Test cleanup temp files should check nonexistent''' self.tr_cpio._transfer_list = [{ 'action': 'install', 'cpio_args': '-pdum', 'contents': '/noexist' }] try: self.tr_cpio._cleanup_tmp_files() except Exception as err: self.fail(str(err)) def test_cpio_w_file_list_file(self): '''Test copy of a file list file succeeds''' # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir # using a file list file as the contents souce # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_FILE_LIST_FILE with open(self.TEST_FILE_LIST_FILE, 'w') as filehandle: filehandle.write("bin/xclock" + "\n") filehandle.write("bin/pv.sh" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_file_list(self): '''Test copy from a list succeeds''' # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir # using a file list as the contents source # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.TEST_CONTENTS_LIST.append("bin/xclock") self.TEST_CONTENTS_LIST.append("bin/pv.sh") self.tr_node.action = "install" self.tr_node.contents = self.TEST_CONTENTS_LIST try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_dir_list_file(self): '''Test directory cpio copy succeeds''' # Copy all the directories and files from /etc/X11 and /etc/zones # to /rpool/cpio_test_dir using a file for the contents # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_DIR_LIST_FILE with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle: filehandle.write("etc/X11" + "\n") filehandle.write("etc/zones" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_dir_list(self): '''Test copying a list of directories and files succeeds''' # Copy all the directories and files from /etc/X11 and /etc/zones # to /rpool/cpio_test_dir using a list for the contents # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) self.TEST_CONTENTS_LIST.append("bin/xclock") self.TEST_CONTENTS_LIST.append("bin/pv.sh") # The CPIO values that are specified self.TEST_CONTENTS_LIST.append("etc/X11") self.TEST_CONTENTS_LIST.append("etc/zones") self.tr_node.action = "install" self.tr_node.contents = self.TEST_CONTENTS_LIST try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_non_default_args_set(self): '''Test copying a list of directories and files succeeds''' # Copy all the directories and files from /etc/X11 and /etc/zones # to /rpool/cpio_test_dir using a list for the contents # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) args = Args({"cpio_args": "-n -d -pdum"}) self.tr_node.insert_children([args]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) self.TEST_CONTENTS_LIST.append("bin/xclock") self.TEST_CONTENTS_LIST.append("bin/pv.sh") # The CPIO values that are specified self.TEST_CONTENTS_LIST.append("etc/X11") self.TEST_CONTENTS_LIST.append("etc/zones") self.tr_node.action = "install" self.tr_node.contents = self.TEST_CONTENTS_LIST try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_empty_list(self): ''' Test that "empty contents list" scenario is handled''' # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = [] try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_no_contents(self): ''' Test that "no contents" scenario is handled''' # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified - no contents self.tr_node.action = "install" try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_skip_file_list_file(self): '''Test the success of using skip_file_list''' # Copy all the files/dirs from /etc except for /etc/name_to_major # to /rpool/cpio_test_dir using a file for the contents # Set up the Source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_DIR_LIST_FILE # Create and insert a node for the files to be uninstalled self.tr_node2 = CPIOSpec() self.tr_node2.action = "uninstall" self.tr_node2.contents = self.TEST_SKIP_FILE_LIST_FILE self.soft_node.insert_children([self.tr_node2]) # Populate the files with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle: filehandle.write("etc/dhcp" + "\n") with open(self.TEST_SKIP_FILE_LIST_FILE, 'w') as filehandle: filehandle.write("etc/dhcp/duid" + "\n") filehandle.write("etc/dhcp/iaid" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_skip_file_list_list(self): '''Test the success of using skip_file_list''' # Copy all the files/dirs from /etc except for /etc/name_to_major # to /rpool/cpio_test_dir using a file for the contents # Set up the Source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" #self.tr_node.contents = self.TEST_DIR_LIST_FILE self.tr_node.contents = ["etc/dhcp"] # Create and insert a node for the files to be uninstalled self.tr_node2 = CPIOSpec() self.tr_node2.action = "uninstall" #self.tr_node2.contents = self.TEST_SKIP_FILE_LIST_FILE self.tr_node2.contents = ["etc/dhcp/duid", "etc/dhcp/iaid"] self.soft_node.insert_children([self.tr_node2]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_dir_excl_list_file(self): '''Test the success of using directory exclusion''' # Copy all files/dirs from /etc/xdg except for anything under # /etc/xdg/menus to /rpool/cpio_test_dir using a file to # specify the contents # Set up the Source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_DIR_LIST_FILE # Populate the dir list file with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle: filehandle.write("etc/xdg" + "\n") # Create and insert a node for the excluded files/dirs self.tr_node2 = CPIOSpec() self.tr_node2.action = "uninstall" self.tr_node2.contents = self.TEST_DIR_EXCL_LIST_FILE self.soft_node.insert_children([self.tr_node2]) # Populate the excl file with open(self.TEST_DIR_EXCL_LIST_FILE, 'w') as filehandle: filehandle.write("etc/xdg/menus" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_src_not_exist(self): ''' Test that an error is raised when src doesn't exist.''' #Set up the source src = Source() path = Dir("/hello") src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_src_not_specified(self): ''' Test that an error is raised when src is not specified''' # Test that an error is raised. dst = Destination() dst_path = self.TEST_DST_DIR path = Dir(dst_path) dst.insert_children([path]) self.soft_node.insert_children([dst]) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_dst_not_specified(self): ''' Test that an error is raised when dst is not specified''' # Test that an error is raised. src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) self.soft_node.insert_children([src]) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_skip_file_list_file_not_valid(self): '''Test that an error is raised for invalid skip_file_list file''' # Set up the source src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "uninstall" self.tr_node.contents = "/tmp/invalid_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_dir_list_not_valid(self): '''Test that an error is raised for invalid dir_list file''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = "/tmp/invalid_dir_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_dir_excl_list_not_valid(self): '''Test that an error is raised for invalid dir_excl_list''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "uninstall" self.tr_node.contents = "/tmp/invalid_dir_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_media_transform_not_valid(self): '''Test that an error is raised for invalid media_transform executable ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "transform" self.tr_node.contents = "/tmp/invalid_transform_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_media_transform_not_executable(self): '''Test media_transform doesn't have correct permissions error ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "transform" self.tr_node.contents = "/tmp/media_not_exec" open(self.tr_node.contents, 'w') os.chmod(self.tr_node.contents, 01666) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=False) try: os.unlink(self.tr_node.contents) except (Exception): pass def test_progress_estimate_invalid_src(self): '''Test the progress estimate value when src is invalid. ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "/bogus") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] try: progress_estimate = self.tr_cpio.get_progress_estimate() except: self.assertTrue(False) self.assertTrue(progress_estimate == self.tr_cpio.DEFAULT_PROG_EST) def test_progress_estimate(self): '''Test that the progress estimate is the value expected.''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["xinit"] try: progress_estimate = self.tr_cpio.get_progress_estimate() except Exception: self.assertTrue(False) size = 0 size += file_size(os.path.join(src_path, "./")) for contents in self.tr_node.contents: size += file_size(os.path.join(src_path, contents)) for root, subdirs, files in os.walk( os.path.join(src_path, contents)): for subdir in subdirs: size += file_size(os.path.join(root, subdir)) for fname in files: size += file_size(os.path.join(root, fname)) # convert size to kilobytes size = size / 1024 self.assertTrue(progress_estimate == \ int(float(size) / self.tr_cpio.DEFAULT_SIZE * \ self.tr_cpio.DEFAULT_PROG_EST)) def test_get_size(self): '''Test that get_size returns an error when no source is set''' dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([dst]) self.assertRaises(IndexError, self.tr_cpio.get_size) def test_progress_estimate_with_size(self): '''Test progress estimate value when size is pre-calculated exists ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] size_to_transfer = dir_size(src_path) self.tr_node.size = str(size_to_transfer) progress_estimate = self.tr_cpio.get_progress_estimate() expect_estimate = \ int((float(size_to_transfer / 1024) / self.tr_cpio.DEFAULT_SIZE) \ * self.tr_cpio.DEFAULT_PROG_EST) self.assertEqual(progress_estimate, expect_estimate) def test_media_transform(self): '''Test media transform functionality''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "transform" self.tr_node.contents = self.TEST_MEDIA_TRANSFORM with open(self.TEST_MEDIA_TRANSFORM, 'w') as filehandle: filehandle.write("#!/usr/bin/python\n") filehandle.write("import os\n") mkdir_cmd = "os.mkdir('" + self.TEST_DST_DIR + "')" filehandle.write(mkdir_cmd + "\n") mkdir_cmd = "os.mkdir('" + os.path.join(self.TEST_DST_DIR, "media") + "')" filehandle.write(mkdir_cmd) os.chmod(self.TEST_MEDIA_TRANSFORM, 0777) try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_checkpoint_soft_node_match(self): '''The checkpoint and software node match ''' try: tr_cpio = TransferCPIO("CPIO_Transfer") except Exception as err: self.fail(str(err)) def test_checkpoint_soft_node_mismatch(self): '''The checkpoint and software node match as expected ''' self.assertRaises(Exception, TransferCPIO, "CPIO Transfer")
class TestCPIOFunctions(unittest.TestCase): TEST_DST_DIR = "/tmp/cpio_test_dir" TEST_SRC_DIR = "/" TEST_FILE_LIST_FILE = "/tmp/test_file_list" TEST_CONTENTS_LIST = [] TEST_DIR_LIST_FILE = "/tmp/test_dir_list" TEST_SKIP_FILE_LIST_FILE = "/tmp/test_skip_file_list" TEST_DIR_EXCL_LIST_FILE = "/tmp/test_dir_excl_list" TEST_MEDIA_TRANSFORM = "/tmp/media_transform" def setUp(self): InstallEngine._instance = None InstallEngine() self.engine = InstallEngine.get_instance() self.doc = self.engine.data_object_cache.volatile self.soft_node = Software("CPIO_Transfer", "CPIO") self.tr_node = CPIOSpec() self.soft_node.insert_children([self.tr_node]) self.doc.insert_children([self.soft_node]) self.tr_cpio = TransferCPIO("CPIO_Transfer") def tearDown(self): if os.access(self.TEST_DST_DIR, os.F_OK): shutil.rmtree(self.TEST_DST_DIR) if os.access(self.TEST_FILE_LIST_FILE, os.F_OK): os.unlink(self.TEST_FILE_LIST_FILE) if os.access(self.TEST_DIR_LIST_FILE, os.F_OK): os.unlink(self.TEST_DIR_LIST_FILE) if os.access(self.TEST_SKIP_FILE_LIST_FILE, os.F_OK): os.unlink(self.TEST_SKIP_FILE_LIST_FILE) if os.access(self.TEST_DST_DIR, os.F_OK): os.unlink(self.TEST_DST_DIR) if os.access(self.TEST_MEDIA_TRANSFORM, os.F_OK): os.unlink(self.TEST_MEDIA_TRANSFORM) if os.access("/tmp/media_not_exec", os.F_OK): os.unlink("/tmp/media_not_exec") self.engine.data_object_cache.clear() self.doc = None self.engine = None self.soft_node = None self.tr_node = None self.tr_cpio = None InstallEngine._instance = None TEST_CONTENTS_LIST = [] def test_software_type(self): self.assertTrue(self.soft_node.tran_type == "CPIO") def test_entire(self): '''Test transfer all of /etc/X11 to /rpool/cpio_test_dir succeeds''' # Set up the source src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cleanup_temp_files(self): '''Test the cleanup of the temporary files''' # Set up the source src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] self.tr_cpio._parse_input() try: self.tr_cpio._cleanup_tmp_files() except Exception as err: self.fail(str(err)) def test_cleanup_temp_files_nonexistent_file(self): '''Test cleanup temp files should check nonexistent''' self.tr_cpio._transfer_list = [{'action': 'install', 'cpio_args': '-pdum', 'contents': '/noexist'}] try: self.tr_cpio._cleanup_tmp_files() except Exception as err: self.fail(str(err)) def test_cpio_w_file_list_file(self): '''Test copy of a file list file succeeds''' # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir # using a file list file as the contents souce # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_FILE_LIST_FILE with open(self.TEST_FILE_LIST_FILE, 'w') as filehandle: filehandle.write("bin/xclock" + "\n") filehandle.write("bin/pv.sh" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_file_list(self): '''Test copy from a list succeeds''' # Copy /bin/xclock and /bin/pv.sh to /rpool/cpio_test_dir # using a file list as the contents source # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.TEST_CONTENTS_LIST.append("bin/xclock") self.TEST_CONTENTS_LIST.append("bin/pv.sh") self.tr_node.action = "install" self.tr_node.contents = self.TEST_CONTENTS_LIST try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_dir_list_file(self): '''Test directory cpio copy succeeds''' # Copy all the directories and files from /etc/X11 and /etc/zones # to /rpool/cpio_test_dir using a file for the contents # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_DIR_LIST_FILE with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle: filehandle.write("etc/X11" + "\n") filehandle.write("etc/zones" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_dir_list(self): '''Test copying a list of directories and files succeeds''' # Copy all the directories and files from /etc/X11 and /etc/zones # to /rpool/cpio_test_dir using a list for the contents # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) self.TEST_CONTENTS_LIST.append("bin/xclock") self.TEST_CONTENTS_LIST.append("bin/pv.sh") # The CPIO values that are specified self.TEST_CONTENTS_LIST.append("etc/X11") self.TEST_CONTENTS_LIST.append("etc/zones") self.tr_node.action = "install" self.tr_node.contents = self.TEST_CONTENTS_LIST try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_non_default_args_set(self): '''Test copying a list of directories and files succeeds''' # Copy all the directories and files from /etc/X11 and /etc/zones # to /rpool/cpio_test_dir using a list for the contents # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) args = Args({"cpio_args": "-n -d -pdum"}) self.tr_node.insert_children([args]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) self.TEST_CONTENTS_LIST.append("bin/xclock") self.TEST_CONTENTS_LIST.append("bin/pv.sh") # The CPIO values that are specified self.TEST_CONTENTS_LIST.append("etc/X11") self.TEST_CONTENTS_LIST.append("etc/zones") self.tr_node.action = "install" self.tr_node.contents = self.TEST_CONTENTS_LIST try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_cpio_w_empty_list(self): ''' Test that an error is raised when contents list is empty''' # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = [] self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_cpio_no_contents(self): ''' Test that an error is raised when no contents exist''' # Set up the source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified - no contents self.tr_node.action = "install" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_skip_file_list_file(self): '''Test the success of using skip_file_list''' # Copy all the files/dirs from /etc except for /etc/name_to_major # to /rpool/cpio_test_dir using a file for the contents # Set up the Source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_DIR_LIST_FILE # Create and insert a node for the files to be uninstalled self.tr_node2 = CPIOSpec() self.tr_node2.action = "uninstall" self.tr_node2.contents = self.TEST_SKIP_FILE_LIST_FILE self.soft_node.insert_children([self.tr_node2]) # Populate the files with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle: filehandle.write("etc/dhcp" + "\n") with open(self.TEST_SKIP_FILE_LIST_FILE, 'w') as filehandle: filehandle.write("etc/dhcp/duid" + "\n") filehandle.write("etc/dhcp/iaid" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_skip_file_list_list(self): '''Test the success of using skip_file_list''' # Copy all the files/dirs from /etc except for /etc/name_to_major # to /rpool/cpio_test_dir using a file for the contents # Set up the Source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" #self.tr_node.contents = self.TEST_DIR_LIST_FILE self.tr_node.contents = ["etc/dhcp"] # Create and insert a node for the files to be uninstalled self.tr_node2 = CPIOSpec() self.tr_node2.action = "uninstall" #self.tr_node2.contents = self.TEST_SKIP_FILE_LIST_FILE self.tr_node2.contents = ["etc/dhcp/duid", "etc/dhcp/iaid"] self.soft_node.insert_children([self.tr_node2]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_dir_excl_list_file(self): '''Test the success of using directory exclusion''' # Copy all files/dirs from /etc/xdg except for anything under # /etc/xdg/menus to /rpool/cpio_test_dir using a file to # specify the contents # Set up the Source src = Source() path = Dir(self.TEST_SRC_DIR) src.insert_children([path]) # Set up the destination dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) # Insert the source and dest into the Software node self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = self.TEST_DIR_LIST_FILE # Populate the dir list file with open(self.TEST_DIR_LIST_FILE, 'w') as filehandle: filehandle.write("etc/xdg" + "\n") # Create and insert a node for the excluded files/dirs self.tr_node2 = CPIOSpec() self.tr_node2.action = "uninstall" self.tr_node2.contents = self.TEST_DIR_EXCL_LIST_FILE self.soft_node.insert_children([self.tr_node2]) # Populate the excl file with open(self.TEST_DIR_EXCL_LIST_FILE, 'w') as filehandle: filehandle.write("etc/xdg/menus" + "\n") try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_src_not_exist(self): ''' Test that an error is raised when src doesn't exist.''' #Set up the source src = Source() path = Dir("/hello") src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_src_not_specified(self): ''' Test that an error is raised when src is not specified''' # Test that an error is raised. dst = Destination() dst_path = self.TEST_DST_DIR path = Dir(dst_path) dst.insert_children([path]) self.soft_node.insert_children([dst]) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_dst_not_specified(self): ''' Test that an error is raised when dst is not specified''' # Test that an error is raised. src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) self.soft_node.insert_children([src]) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_skip_file_list_file_not_valid(self): '''Test that an error is raised for invalid skip_file_list file''' # Set up the source src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "uninstall" self.tr_node.contents = "/tmp/invalid_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_dir_list_not_valid(self): '''Test that an error is raised for invalid dir_list file''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = "/tmp/invalid_dir_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_dir_excl_list_not_valid(self): '''Test that an error is raised for invalid dir_excl_list''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "uninstall" self.tr_node.contents = "/tmp/invalid_dir_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_media_transform_not_valid(self): '''Test that an error is raised for invalid media_transform executable ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "transform" self.tr_node.contents = "/tmp/invalid_transform_file" self.assertRaises(Exception, self.tr_cpio.execute, dry_run=True) def test_media_transform_not_executable(self): '''Test media_transform doesn't have correct permissions error ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "transform" self.tr_node.contents = "/tmp/media_not_exec" open(self.tr_node.contents, 'w') os.chmod(self.tr_node.contents, 01666) self.assertRaises(Exception, self.tr_cpio.execute, dry_run=False) try: os.unlink(self.tr_node.contents) except (Exception): pass def test_progress_estimate_invalid_src(self): '''Test the progress estimate value when src is invalid. ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "/bogus") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] try: progress_estimate = self.tr_cpio.get_progress_estimate() except: self.assertTrue(False) self.assertTrue(progress_estimate == self.tr_cpio.DEFAULT_PROG_EST) def test_progress_estimate(self): '''Test that the progress estimate is the value expected.''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["xinit"] try: progress_estimate = self.tr_cpio.get_progress_estimate() except Exception: self.assertTrue(False) size = 0 size += file_size(os.path.join(src_path, "./")) for contents in self.tr_node.contents: size += file_size(os.path.join(src_path, contents)) for root, subdirs, files in os.walk(os.path.join(src_path, contents)): for subdir in subdirs: size += file_size(os.path.join(root, subdir)) for fname in files: size += file_size(os.path.join(root, fname)) # convert size to kilobytes size = size / 1024 self.assertTrue(progress_estimate == \ int(float(size) / self.tr_cpio.DEFAULT_SIZE * \ self.tr_cpio.DEFAULT_PROG_EST)) def test_get_size(self): '''Test that get_size returns an error when no source is set''' dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([dst]) self.assertRaises(IndexError, self.tr_cpio.get_size) def test_progress_estimate_with_size(self): '''Test progress estimate value when size is pre-calculated exists ''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "install" self.tr_node.contents = ["./"] size_to_transfer = dir_size(src_path) self.tr_node.size = str(size_to_transfer) progress_estimate = self.tr_cpio.get_progress_estimate() expect_estimate = \ int((float(size_to_transfer/1024) / self.tr_cpio.DEFAULT_SIZE) * \ self.tr_cpio.DEFAULT_PROG_EST) self.assertEqual(progress_estimate, expect_estimate) def test_media_transform(self): '''Test media transform functionality''' src = Source() src_path = os.path.join(self.TEST_SRC_DIR, "etc/X11") path = Dir(src_path) src.insert_children([path]) dst = Destination() path = Dir(self.TEST_DST_DIR) dst.insert_children([path]) self.soft_node.insert_children([src, dst]) # The CPIO values that are specified self.tr_node.action = "transform" self.tr_node.contents = self.TEST_MEDIA_TRANSFORM with open(self.TEST_MEDIA_TRANSFORM, 'w') as filehandle: filehandle.write("#!/usr/bin/python\n") filehandle.write("import os\n") mkdir_cmd = "os.mkdir('" + self.TEST_DST_DIR + "')" filehandle.write(mkdir_cmd + "\n") mkdir_cmd = "os.mkdir('" + os.path.join(self.TEST_DST_DIR, "media") + "')" filehandle.write(mkdir_cmd) os.chmod(self.TEST_MEDIA_TRANSFORM, 0777) try: self.tr_cpio.execute(dry_run=True) except Exception as err: self.fail(str(err)) def test_checkpoint_soft_node_match(self): '''The checkpoint and software node match ''' try: tr_cpio = TransferCPIO("CPIO_Transfer") except Exception as err: self.fail(str(err)) def test_checkpoint_soft_node_mismatch(self): '''The checkpoint and software node match as expected ''' self.assertRaises(Exception, TransferCPIO, "CPIO Transfer")
def test_info(self): '''Test that all the arguments get into the node correctly''' soft_node = Software("CPIO transfer test 1") cpio_node = CPIOSpec() dst = Destination() path = Dir("/a") dst.insert_children([path]) src = Source() path = Dir("/bin") src.insert_children([path]) # first check src and dst soft_node.insert_children([dst, src, cpio_node]) self.doc.insert_children([soft_node]) soft_list = self.doc.get_children("CPIO transfer test 1", Software) for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: try: args = tr.get_children("args", Args)[0] except: self.assertTrue(True) self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(tr.action, None) self.assertEqual(tr.contents, None) # set cpio args args = Args({"cpio_args": "-pdm"}) cpio_node.insert_children([args]) # Check that we can read the attributes out correctly for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: args = tr.get_children("args", Args)[0] self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(args.arg_dict["cpio_args"], "-pdm") self.assertEqual(tr.action, None) self.assertEqual(tr.contents, None) # set file_list content cpio_node.action = "install" cpio_node.type = "FILE" cpio_node.contents = "/usr/share/tr_file_list" # Check that we can read the attributes out correctly for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: args = tr.get_children("args", Args)[0] self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(args.arg_dict["cpio_args"], "-pdm") self.assertEqual(tr.action, "install") self.assertEqual(tr.contents, "/usr/share/tr_file_list") # set dir_list cpio_node.action = "install" cpio_node.type = "DIR" cpio_node.contents = "/usr/share/tr_dir_list" # Check that we can read the attributes out correctly for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: args = tr.get_children("args", Args)[0] self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(args.arg_dict["cpio_args"], "-pdm") self.assertEqual(tr.action, "install") self.assertEqual(tr.contents, "/usr/share/tr_dir_list") # set skip_file_list cpio_node.action = "uninstall" cpio_node.type = "FILE" cpio_node.contents = "/usr/share/tr_skip_file_list" # Check that we can read the attributes out correctly for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: args = tr.get_children("args", Args)[0] self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(args.arg_dict["cpio_args"], "-pdm") self.assertEqual(tr.action, "uninstall") self.assertEqual(tr.contents, "/usr/share/tr_skip_file_list") # set dir_excl_list cpio_node.action = "uninstall" cpio_node.type = "DIR" cpio_node.contents = "/usr/share/tr_dir_excl_list" # Check that we can read the attributes out correctly for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: args = tr.get_children("args", Args)[0] self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(args.arg_dict["cpio_args"], "-pdm") self.assertEqual(tr.action, "uninstall") self.assertEqual(tr.contents, "/usr/share/tr_dir_excl_list") # set media transform cpio_node.action = "transform" cpio_node.type = "None" cpio_node.contents = "/usr/share/media_transform" # Check that we can read the attributes out correctly for soft in soft_list: src_list = soft.get_children("source", Source) self.assertEqual(len(src_list), 1) src_path = src_list[0].get_children("dir", Dir) self.assertEqual(len(src_path), 1) src = src_path[0].dir_path dst_list = soft.get_children("destination", Destination) self.assertEqual(len(dst_list), 1) dst_path = dst_list[0].get_children("dir", Dir) self.assertEqual(len(dst_path), 1) dst = dst_path[0].dir_path tr_list = soft.get_children("transfer", CPIOSpec) for tr in tr_list: args = tr.get_children("args", Args)[0] self.assertEqual(dst, "/a") self.assertEqual(src, "/bin") self.assertEqual(args.arg_dict["cpio_args"], "-pdm") self.assertEqual(tr.action, "transform") self.assertEqual(tr.contents, "/usr/share/media_transform")