Skip to content

Manual DOS CLI Testing

MeAreJeenius edited this page Apr 9, 2024 · 7 revisions

This page is for manual internal command line interface (the shell, the builtin commands, packaged "external" programs, etc.) tests. Unit tests are generally preferred, but sometimes manual tests are required either due to the inherent nature of the tests, or the implementation not being in a testable state.

CONFIG Command

Set CONFIG Environment Variable

  • Run CONFIG -GET VER
  • SET CONFIG should display the currently set DOS version
  • Reset the variable with SET CONFIG=
  • Run CONFIG -GET DOS VER
  • SET CONFIG should display the currently set DOS version

DIR Command

DIRCMD

  • Run SET DIRCMD= to clear the environment variable
  • Run DIR and note how it displays timestamps
  • Run DIR /B and note how it does not display timestamps
  • Run SET DIRCMD=/B
  • Run DIR again and note how there are no timestamps, as with DIR /B

ECHO Command

Batch File Inheritance

  • Create two files with the following contents in the same directory:
:: file1.bat

echo off
file2.bat
:: file2.bat

REM THIS SHOULDN'T BE PRINTED VIA FILE1.BAT
  • Run ECHO ON
  • Upon running FILE1.BAT, the contents of FILE2.BAT should not be printed

FOR Command

Wildcard Matching

Ensure that any instances of wildcards (* and ?) in the for command's string set properly expand to the expected files in the current directory.

Examples:

FOR %C IN (*.TXT) DO ECHO %C -> Echoes all .TXT files in the current directory.

FOR %C IN (A??.*) DO ECHO %C -> Echoes all files in the current directory which start with 'A', and which have a name of at MOST 3 characters and an extension.

PATH Command

The output of PATH and SET PATH should display the same contents, except that the PATH command doesn't display the preceeding PATH= before the directories

RENAME Command

Wildcard Matching

Wildcards are handled in both source and target of the rename. For the source, it collects a list of all files that match the wildcard in a fairly obvious manner (should be identical to the FOR command above).

Wildcards are expanded separately for the name and the extension.

It's a little tricky to explain how it expands the target wildcards so best to show examples.

Examples (these have been tested in both Dosbox Staging and real MS-DOS 6.22 via 86Box):

ren gamemaps.a test*.b -> file gets renamed to testmaps.b

ren *.a *.b -> changes extensions of all .a files to .b

ren a.exe test* -> file gets renamed to test (the a gets dropped since test is longer. the extension also gets dropped because there was no . in the target).

ren gamemaps.a test*foo.c -> file gets renamed to testmaps.c (anything after a * (foo in this case) gets ignored, extension gets changed as that is expanded separately from the name).

ren gamemaps.a ?test?.* -> file gets renamed to gtesta.a(? expands to a single character from the source in the same position. .* keeps the file extension the same).

SET Command

Add a variable

  • Enter SET EXAMPLE=VALUE
  • Entering SET EXAMPLE should display EXAMPLE=VALUE
  • Entering SET should display all environment variables, including EXAMPLE

Remove a variable

  • Enter SET EXAMPLE=
  • Entering SET EXAMPLE should display a message saying EXAMPLE is not defined
  • Entering SET should display all environment variables and EXAMPLE should no longer be listed

SETVER Command

Errors

The following should display an error message

  • SETVER X
  • SETVER /B BAD ARGS

Piping Commands

TMP and TEMP

Testing to make sure that these environment variables work involves looking at access timestamps for the relevant directories. This is because temporary files are deleted after they are used, so there are no traces of the file left to verify.

  • Create a new temporary directory with MKDIR TEMPDIR
  • Run SET TEMP=TEMPDIR
  • Wait one minute to allow the directory timestamp to go out of date
  • Run A | PAUSE
  • Run DIR and make sure the timestamp of TEMPDIR is set to when the previous command was run
  • Run SET TMP=TEMPDIR, then SET TEMP=, then repeat the prevous three steps

Shell Expansion

expand_shell_variable = false in config

  • Run ECHO ECHO %PATH% > PRNTPTH.BAT
  • PRNTPTH.BAT should print the contents of the PATH environment variable

expand_shell_variable = true in config

  • ECHO %PATH% should print the contents of the PATH environment variable

Shell History

Encoding

  • Run KEYB US
  • Run ECHO é (é -> ALT+130)
  • Reset DOSBox
  • Run KEYB US
  • The most recent command should be ECHO é

Permissions

No Read

  • Navigate to $DOSBOX_CONFIG/shell_history.txt
  • Remove the file's read permissions
    • (Linux) chmod u-r
  • Start DOSBox
  • Apart from having no history, DOSBox should be working as expected

No Write

  • Navigate to $DOSBOX_CONFIG/shell_history.txt
  • Remove the file's write permissions
    • (Linux) chmod u-w
  • Start DOSBox
  • Shell history should still be visible (press up key to check)

Size Limit

  • Navigate to $DOSBOX_CONFIG/shell_history.txt
  • Fill it with over 500 non-empty lines
    • (Bash) for i in `seq 1 501`; do echo $i >> $DOSBOX_CONFIG/shell_history.txt; done
  • Open DOSBox, then close it.
  • Shell history file should only contain the 500 most recent lines

Unsaved Commands

Exit

  • Run COMMAND
  • Run EXIT
  • Pressing the up arrow should give COMMAND

Consectutive Repetition

  • Run ECHO 1
  • Run ECHO 2 three times
  • Pressing the up arrow should give ECHO 2
  • Pressing up again should give ECHO 1

New History File

  • Check that DOSBox is not open
  • Delete $DOSBOX_CONFIG/shell_history.txt
  • Open DOSBox
  • Close DOSBox
  • Check that a new $DOSBOX_CONFIG/shell_history.txt has been made
Clone this wiki locally