Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I get what you want; this might get you started:</p> <p>A mix of bash + external tools like diff.</p> <pre><code>#!/bin/bash # If number of arguments less then 1; print usage and exit if [ $# -lt 1 ]; then printf "Usage: %s &lt;application&gt;\n" "$0" &gt;&amp;2 exit 1 fi bin="$1" # The application (from command arg) diff="diff -iad" # Diff command, or what ever # An array, do not have to declare it, but is supposedly faster declare -a file_base=("file1" "file2" "file3") # Loop the array for file in "${file_base[@]}"; do # Padd file_base with suffixes file_in="$file.in" # The in file file_out_val="$file.out" # The out file to check against file_out_tst="$file.out.tst" # The outfile from test application # Validate infile exists (do the same for out validate file) if [ ! -f "$file_in" ]; then printf "In file %s is missing\n" "$file_in" continue; fi if [ ! -f "$file_out_val" ]; then printf "Validation file %s is missing\n" "$file_out_val" continue; fi printf "Testing against %s\n" "$file_in" # Run application, redirect in file to app, and output to out file "./$bin" &lt; "$file_in" &gt; "$file_out_tst" # Execute diff $diff "$file_out_tst" "$file_out_val" # Check exit code from previous command (ie diff) # We need to add this to a variable else we can't print it # as it will be changed by the if [ # Iff not 0 then the files differ (at least with diff) e_code=$? if [ $e_code != 0 ]; then printf "TEST FAIL : %d\n" "$e_code" else printf "TEST OK!\n" fi # Pause by prompt read -p "Enter a to abort, anything else to continue: " input_data # Iff input is "a" then abort [ "$input_data" == "a" ] &amp;&amp; break done # Clean exit with status 0 exit 0 </code></pre> <hr> <p>Edit.<br /></p> <p>Added exit code check; And a short walk trough:</p> <p>This will in short do:</p> <ol> <li>Check if argument is given (bin/application)</li> <li>Use an array of "base names", loop this and generate real filenames. <ul> <li>I.e.: Having array <code>("file1" "file2")</code> you get<br /> <ul> <li>In file: <code>file1.in</code></li> <li>Out file to validate against: <code>file1.out</code></li> <li>Out file: <code>file1.out.tst</code></li> <li>In file: <code>file2.in</code></li> <li>...</li> </ul></li> </ul></li> <li>Execute application and redirect in file to <code>stdin</code> for application by <code>&lt;</code>, and redirect <code>stdout</code> from application to out file test by <code>&gt;</code>.</li> <li>Use a tool like i.e. <code>diff</code> to test if they are the same.</li> <li>Check exit / return code from tool and print message (FAIL/OK)</li> <li>Prompt for continuance.</li> </ol> <p>Any and all of which off course can be modified, removed etc.</p> <hr> <p>Some links:</p> <ul> <li><a href="http://tldp.org/LDP/abs/html/" rel="nofollow">TLDP; Advanced Bash-Scripting Guide</a> (can be a bit more readable with <a href="http://userstyles.org/styles/browse/all/tldp" rel="nofollow">this</a>) <ul> <li><a href="http://tldp.org/LDP/abs/html/arrays.html" rel="nofollow">Arrays</a></li> <li><a href="http://tldp.org/LDP/abs/html/fto.html" rel="nofollow">File test operators</a></li> <li><a href="http://tldp.org/LDP/abs/html/loops.html" rel="nofollow">Loops and branches</a></li> <li><a href="http://tldp.org/LDP/abs/html/exit-status.html" rel="nofollow">Exit-status</a></li> <li>...</li> </ul></li> <li><a href="http://www.thegeekstuff.com/2010/06/bash-array-tutorial/" rel="nofollow">bash-array-tutorial</a></li> <li><a href="http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html" rel="nofollow">TLDP; Bash-Beginners-Guide</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload