From 378c18e5f024ac5a8aef4cb40d7c9aa9633d144c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:30:35 +0200 Subject: Adding upstream version 2.38.1. Signed-off-by: Daniel Baumann --- libmount/python/test_mount_tab_update.py | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 libmount/python/test_mount_tab_update.py (limited to 'libmount/python/test_mount_tab_update.py') diff --git a/libmount/python/test_mount_tab_update.py b/libmount/python/test_mount_tab_update.py new file mode 100755 index 0000000..a16e9e3 --- /dev/null +++ b/libmount/python/test_mount_tab_update.py @@ -0,0 +1,59 @@ +import os +import sys +import stat +import errno + +# use "import libmount" for in a standard way installed python binding +import pylibmount as mnt + +def usage(tss): + print("\nUsage:\n\t{:s} [testoptions]\nTests:\n".format(sys.argv[0])) + for i in tss: + print("\t{15:-s}".format(i[0])) + if i[2] != "": + print(" {:s}\n".format(i[2])) + + print("\n") + return 1 + +def mnt_run_test(tss, argv): + rc = -1 + if ((len(argv) < 2) or (argv[1] == "--help") or (argv[1] == "-h")): + return usage(tss) + + #mnt_init_debug(0) + + i=() + for i in tss: + if i[0] == argv[1]: + rc = i[1](i, argv[1:]) + if rc: + print("FAILED [rc={:d}]".format(rc)) + break + + if ((rc < 0) and (i == ())): + return usage(tss) + return not not rc #because !!rc is too mainstream for python + +def test_replace(ts, argv): + fs = mnt.Fs() + tb = mnt.Table() + + if (len(argv) < 3): + return -1 + tb.enable_comments(True) + tb.parse_fstab() + + fs.source = argv[1] + fs.target = argv[2] + #TODO: resolve None + string + fs.comment = "# this is new filesystem\n" + tb.add_fs(fs) + tb.replace_file(os.environ["LIBMOUNT_FSTAB"]) + return 0 + +tss = ( + ( "--replace",test_replace, " Add a line to LIBMOUNT_FSTAB and replace the original file" ), +) + +sys.exit(mnt_run_test(tss, sys.argv)) -- cgit v1.2.3