. "$BST_LIB" # mtools 4.0.49, part 1 of 3 — the shipped PAYLOAD and the OPTION surface. # # Part 2 (65-mtools-fmt.test) covers the codepage contract, mformat geometry and # the device-level tools; part 3 (65-mtools-files.test) the file operations. All # three emit mtools/* ids, so `brintos-selftest mtools` selects the whole surface; # only the runner's 60 s per-suite wall-clock accounting is split — a three-way # split rather than dosfstools' two because this surface is 184 cases and a # process spawn costs ~0.5 s here. # # Every expectation was measured against a native mtools 4.0.49 built from the # same tarball with the SAME configure answer this port needs # (ac_cv_header_iconv_h=no --without-x --disable-floppyd) under LC_ALL=C, then # re-measured on target. Two in this file are counter-intuitive enough that a # suite written from expectation would have shipped false reds: # * mtools is ONE binary and every tool name is an argv[0] symlink onto it, so # unlike dosfstools' compat spellings the name it is invoked as SELECTS the # command — which is why -V reports the name rather than "mtools". # * `mshortname` with no arguments exits 0 while every other tool exits 1, and # `mtoolstest` exits 0 because it is a config dumper rather than a command. require mtools mtools/present BIN=/usr/bin LC_ALL=C; export LC_ALL check_msg() { _i=$1; _n=$2; shift 2 _o=$("$@" 2>&1) case "$_o" in *"$_n"*) bst_ok "$_i" ;; *) bst_notok "$_i" "want:'$_n' got:'$(_bst_1line "$_o")'" ;; esac } # ---------------------------------------------------------------- A. payload -- # ONE real binary plus mkmanifest; everything else is a symlink onto it. for t in mtools mkmanifest; do check "mtools/bin-$t" test -f "$BIN/$t" check_eq "mtools/wasm-$t" "0061736d" \ "$(dd if="$BIN/$t" bs=1 count=4 2>/dev/null | od -An -tx1 | tr -d ' \n')" done # The 24 argv[0] names, asserted as one case plus a count: a case per name would # spend a fifth of the suite's whole time budget on one bit of information. LINKS="mattrib mbadblocks mcat mcd mcopy mdel mdeltree mdir mdoctorfat mdu \ mformat minfo mlabel mmd mmount mmove mpartition mrd mren mshortname mshowfat \ mtoolstest mtype mzip" bad=; n=0 for l in $LINKS; do n=$((n+1)) [ "$(readlink "$BIN/$l" 2>/dev/null)" = mtools ] || bad="$bad $l" done check_eq "mtools/links-all-to-mtools" "" "$bad" check_eq "mtools/links-count" "24" "$n" # the shell scripts the package ships beside the binary, and uz's alias for s in amuFormat.sh mcheck mcomp mxtar tgz uz; do check "mtools/script-$s" test -x "$BIN/$s" done check_eq "mtools/script-lz-alias" "uz" "$(readlink "$BIN/lz")" # every spelling resolves by bare name => /usr/bin is on PATH for t in mdir mformat mcopy mtype mlabel minfo; do check "mtools/path-$t" command -v "$t" done # The image ships NO /etc/mtools.conf, so the drive table is mtools' compiled-in # one. Every case that names a drive letter therefore supplies its own MTOOLSRC; # everything else uses -i, which needs no drive table at all. check_rc "mtools/no-etc-conf" 1 test -e /etc/mtools.conf # ...and no gconv module directory, which is WHY this port is built without # iconv (see part 2). If this ever starts existing, revisit the bbappend rather # than leaving the bundled tables in place by inertia. check_rc "mtools/no-gconv-dir" 1 test -d /usr/lib/gconv # ------------------------------------------------- B. version / option surface -- check_out "mtools/version-V" "mtools (GNU mtools) 4.0.49" mtools -V check_out "mtools/version-long" "mtools (GNU mtools) 4.0.49" mtools --version # -V is a version switch on EVERY name and reports the name it was invoked as, # which is the clearest proof that argv[0] selects the command. check_out "mtools/version-mdir" "mdir (GNU mtools) 4.0.49" mdir -V check_out "mtools/version-mformat" "mformat (GNU mtools) 4.0.49" mformat -V check_out "mtools/version-mcopy" "mcopy (GNU mtools) 4.0.49" mcopy -V check_out "mtools/version-mtype" "mtype (GNU mtools) 4.0.49" mtype -V # The binary prints its own configure options, so the built configuration is # assertable on target rather than inferred from the recipe. check_out "mtools/configured-with" \ "enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term" mtools -V # the shared usage banner and the shared "invalid option" path check_msg "mtools/usage-banner" "Mtools version 4.0.49, dated June 14th, 2025" mcopy for t in mdir mformat mcopy mtype mmd mdel mren; do check_rc "mtools/badopt-rc-$t" 1 "$t" --nonsense check_msg "mtools/badopt-msg-$t" "invalid option" "$t" --nonsense done # no-argument exit statuses for t in mdir mformat mcopy mtype mdel mmd mrd mdu mattrib mren mmove mdeltree \ mcat mbadblocks mpartition mshowfat mzip mdoctorfat mkmanifest; do check_rc "mtools/noargs-rc-$t" 1 "$t" done check_rc "mtools/noargs-rc-mshortname" 0 mshortname check_rc "mtools/noargs-rc-mtoolstest" 0 mtoolstest # each tool's usage line names itself check_msg "mtools/usage-mcopy" "Usage: mcopy" mcopy check_msg "mtools/usage-mdel" "Usage: mdel" mdel check_msg "mtools/usage-mdu" "Usage: mdu" mdu # With no -i and no config file a bare tool falls back to drive A: = /dev/fd0, # which this image has not got — the compiled-in table's own default, reached. check_msg "mtools/noargs-msg-mdir" "Can't open /dev/fd0" mdir check_msg "mtools/noargs-msg-minfo" "Could not open drive" minfo check_msg "mtools/nodrive-mformat" "Drive letter missing" mformat # ...and that compiled-in table is what mtoolstest dumps check_out "mtools/builtin-drive-a" "drive A:" mtoolstest check_out "mtools/builtin-drive-mark" "builtin" mtoolstest check_out "mtools/builtin-fd0" "/dev/fd0" mtoolstest