diff options
Diffstat (limited to 'test/latex')
| -rw-r--r-- | test/latex/candperm.commands.tex.exp | 60 | ||||
| -rw-r--r-- | test/latex/candperm.sail | 67 | ||||
| -rwxr-xr-x | test/latex/run_tests.sh | 57 |
3 files changed, 184 insertions, 0 deletions
diff --git a/test/latex/candperm.commands.tex.exp b/test/latex/candperm.commands.tex.exp new file mode 100644 index 00000000..df253d71 --- /dev/null +++ b/test/latex/candperm.commands.tex.exp @@ -0,0 +1,60 @@ +\providecommand\saildoclabelled[2]{\phantomsection\label{#1}#2} + +\newcommand{\sailtypeast}{\saildoclabelled{typezast}{\saildoctype{}{\lstinputlisting[language=sail]{out/typezast6bb070d12e82e4887160cdfd016230c8.tex}}}} + +\newcommand{\sailvalexecute}{\saildoclabelled{zexecute}{\saildocval{}{\lstinputlisting[language=sail]{out/valzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermBrokenexecute}{\saildoclabelled{fclCAndPermBrokenzexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \hyperref\hyperref[ztablezGpseudocodezDconstants]{\lstinline{table:pseudocode-constants}}{\emph{first\_uperm}} .. +\hyperref\hyperref[ztablezGpseudocodezDconstants]{\lstinline{table:pseudocode-constants}}{\emph{last\_uperm}} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermBrokenzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermEscapedexecute}{\saildoclabelled{fclCAndPermEscapedzexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \hyperref[table:pseudocode-constants]{\emph{first\_uperm}} .. +\hyperref[table:pseudocode-constants]{\emph{last\_uperm}} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermEscapedzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermMarkdownexecute}{\saildoclabelled{fclCAndPermMarkdownzexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \hyperref[table:pseudocode-constants]{*first_uperm*} .. +\hyperref[table:pseudocode-constants]{*last_uperm*} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermMarkdownzexecute33a689e3a631b9b905b85461d3814943.tex}}}} + +\newcommand{\sailfclCAndPermMarkdownWithRefMacroexecute}{\saildoclabelled{fclCAndPermMarkdownWithRefMacrozexecute}{\saildocfcl{Capability register \emph{cd} is replaced with the contents of capability +register \emph{cs1} with the \cperms{} field set to the bitwise-AND of +its previous value and bits 0 .. 10 of integer register \emph{rs2} +and the \cuperms{} field set to the bitwise and of its previous value +and bits \firstUPerm{} .. \lastUPerm{} of \emph{rd}. + +}{\lstinputlisting[language=sail]{out/fclCAndPermMarkdownWithRefMacrozexecute33a689e3a631b9b905b85461d3814943.tex}}}} + + + +\newcommand{\sailval}[1]{ + \ifstrequal{#1}{execute}{\sailvalexecute}{}} + +\newcommand{\sailrefval}[2]{ + \ifstrequal{#1}{execute}{\hyperref[zexecute]{#2}}{}} + +\newcommand{\sailfn}[1]{ + } + +\newcommand{\sailreffn}[2]{ + } + +\newcommand{\sailtype}[1]{ + \ifstrequal{#1}{ast}{\sailtypeast}{}} + +\newcommand{\sailreftype}[2]{ + \ifstrequal{#1}{ast}{\hyperref[typezast]{#2}}{}} diff --git a/test/latex/candperm.sail b/test/latex/candperm.sail new file mode 100644 index 00000000..75482db1 --- /dev/null +++ b/test/latex/candperm.sail @@ -0,0 +1,67 @@ +default Order dec + +scattered union ast('datasize : Int, 'destsize : Int, 'regsize : Int) +val execute : forall ('datasize : Int) ('destsize : Int) ('regsize : Int). + ast('datasize, 'destsize, 'regsize) -> unit + +/* Note: need at least two function clauses to generate latex output */ +scattered function execute +/* + * The naive copy-paste of the existing latex fails due to [] being interpreted as a link. + */ +union clause ast = CAndPermBroken : (int, int, int) +/*! + * Capability register \emph{cd} is replaced with the contents of capability + * register \emph{cs1} with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register \emph{rs2} + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits \hyperref[table:pseudocode-constants]{\emph{first\_uperm}} .. + * \hyperref[table:pseudocode-constants]{\emph{last\_uperm}} of \emph{rd}. + */ +function clause execute(CAndPermBroken(cd, cs1, rs2)) = { + /* Implementation */ + return () +} +union clause ast = CAndPermEscaped : (int, int, int) +/*! + * Capability register \emph{cd} is replaced with the contents of capability + * register \emph{cs1} with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register \emph{rs2} + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits \hyperref\[table:pseudocode-constants\]{\emph{first\_uperm}} .. + * \hyperref\[table:pseudocode-constants\]{\emph{last\_uperm}} of \emph{rd}. + */ +function clause execute(CAndPermEscaped(cd, cs1, rs2)) = { + /* Implementation */ + return () +} + +union clause ast = CAndPermMarkdown : (int, int, int) +/*! + * Capability register *cd* is replaced with the contents of capability + * register *cs1* with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register *rs2* + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits [*first_uperm*][<table:pseudocode-constants>] .. + * [*last_uperm*][<table:pseudocode-constants>] of *rd*. + */ +function clause execute(CAndPermMarkdown(cd, cs1, rs2)) = { + /* Implementation */ + return () +} + +union clause ast = CAndPermMarkdownWithRefMacro : (int, int, int) +/*! + * Capability register *cd* is replaced with the contents of capability + * register *cs1* with the \cperms{} field set to the bitwise-AND of + * its previous value and bits 0 .. 10 of integer register *rs2* + * and the \cuperms{} field set to the bitwise and of its previous value + * and bits \firstUPerm{} .. \lastUPerm{} of *rd*. + */ +function clause execute(CAndPermMarkdownWithRefMacro(cd, cs1, rs2)) = { + /* Implementation */ + return () +} + +end execute +end ast diff --git a/test/latex/run_tests.sh b/test/latex/run_tests.sh new file mode 100755 index 00000000..6ba3ce6f --- /dev/null +++ b/test/latex/run_tests.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$DIR" +SAILDIR="$DIR/../.." + +rm -f "$DIR/tests.xml" + +# shellcheck source=../test_helpers.sh +source "$SAILDIR/test/test_helpers.sh" + + +printf "<testsuites>\n" >> "$DIR/tests.xml" + +find . -name '*.sail' -print0 | while IFS= read -r -d '' line; do + echo "$line" +done + +for testfile in *.sail; do + temp_dir=$(mktemp -d) + trap 'rm -rf $temp_dir' 0 2 3 15 + + if (cd "$temp_dir" && "$SAILDIR/sail" -o "out" -latex "$DIR/$testfile"); then + # compare with expected files + exp_prefix=${testfile//.sail/} + errmsg="Missing .exp files for $testfile?" + for expected in "${exp_prefix}"*.exp; do + echo "expected=$expected" + # remove prefix and suffix + exp_file_name=${expected//${exp_prefix}./} + generated_file="$temp_dir/out/${exp_file_name//.exp/}" + if [ ! -f "$generated_file" ]; then + errmsg="missing expected output $generated_file" + break; + elif ! diff -q "$generated_file" "$expected"; then + diff -u "$generated_file" "$expected" || true + errmsg="output is different" + break + else + errmsg="" + fi + done + if [ -z "$errmsg" ]; then + green "LaTeX for $testfile" "ok" + else + yellow "LaTeX for $testfile" "$errmsg" + fi; + else + red "failed to generate latex for $testfile" "fail" + fi + rm -rf "$temp_dir" +done + +finish_suite "LaTeX testing" + +printf "</testsuites>\n" >> "$DIR/tests.xml" |
