-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jkool702
committed
Jul 29, 2024
1 parent
17afb81
commit 60ca49e
Showing
5 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
#testDir='/usr' | ||
useRamdiskFlag=true | ||
|
||
################################################################################ | ||
|
||
: "${testDir:=/usr}" "${useRamdiskFlag:=false}" | ||
|
||
[[ ${useRamdiskFlag} == 'true' ]] || useRamdiskFlag=false | ||
[[ -d "${testDir}" ]] || { printf '\n\nERROR: can not access "%s". Perhaps due to permissions issues?\n\nABORTING\n\n' "${testDir}"; exit 1; } | ||
|
||
unset forkrun | ||
{ [[ -f ./forkrun.bash ]] && source ./forkrun.bash; } | ||
declare -F forkrun &>/dev/null || source <(curl https://raw.githubusercontent.com/jkool702/forkrun/main/forkrun.bash) | ||
declare -F forkrun &>/dev/null || { [[ -f ./forkrun.bash ]] && source ./forkrun.bash; } | ||
|
||
which nproc 1>/dev/null 2>/dev/null && nProcs=$(nproc) || nProcs=8 | ||
|
||
if ${useRamdiskFlag}; then | ||
mkdir -p /mnt/ramdisk/ | ||
grep -qF '/mnt/ramdisk' <<</proc/mounts || mount -t tmpfs tmpfs /mnt/ramdisk | ||
|
||
mkdir -p /mnt/ramdisk/forkrun_unit-tests_data | ||
rsync -a --max-size=$((1<<20)) "${testDir}" /mnt/ramdisk/forkrun_unit-tests_data | ||
|
||
mapfile -t -d '' A < <(find /mnt/ramdisk/forkrun_unit-tests_data -type f -print0) | ||
else | ||
mapfile -t -d '' A < <(find "${testDir}" -type f -print0) | ||
fi | ||
|
||
fStr=('printf '"'"'%s\n'"'" sha1sum sha256sum) | ||
kStr=('' '-k') | ||
|
||
kFix=('| sort' '') | ||
fFix=('' '| sed -E s/'"'"'^[0-9a-f]{40}[ \t]*'"'"'//' '| sed -E s/'"'"'^[0-9a-f]{64}[ \t]*'"'"'//') | ||
|
||
mapfile -t runArgsA < <(echo {-k\ ,}{-j\ 27\ ,}{-l\ 1\ ,}{-t\ \/tmp\ ,}{-D\ ,}{"${fStr[$fInd]}"\ ,--\ "${fStr[$fInd]}"\ ,-i\ "${fStr[$fInd]}"\ \{\}\ ,-i\ --\ "${fStr[$fInd]}"\ \{\}\ }$'\n') | ||
|
||
for nArgs in $(( ${nProcs} - 2 )) $(( ${nProcs} + 2 )) $(( ${nProcs} * 128 )) $(( ${nProcs} * 1024 )) ; do | ||
printf '--------------------------------------------------\nBEGINNING TEST CASE FOR STDIN LENGTH = %s\n\n' "${nArgs[$nn]}" | ||
|
||
for fInd in 0 1 2; do | ||
mapfile -t C < <(printf '%s\x00' "${A[@]}" | shuf -z -n ${nArgs}); | ||
for runArgs in "${runArgsA[@]}"; do | ||
|
||
[[ "${runArgs}" == '-k'* ]] && kInd=1 || kInd=0 | ||
|
||
source <(printf '%s' \(\ \{\ diff\ 2\>/dev/null\ -q\ -B\ -E\ -Z\ -d\ -a\ -b\ -w\ \<\(printf\ \'%s\\n\'\ \"\$\{C\[@\]\}\"\ \|\ forkrun\ 2\>/dev/null\ "${runArgs}"\ "${fStr[$fInd]}"\ "${fFix[$fInd]}"\ "${kFix[$kInd]}"\ \)\ \<\(printf\ \'%s\\n\'\ \"\$\{C\[@\]\}\"\ "${kFix[$kInd]}"\)\ \&\&\ printf\ \'%s\'\ \"PASS\"\ \|\|\ printf\ \'%s\'\ \"FAIL\"\;\ printf\ \'\:\ %s\\n\'\ \'printf\ \'\"\'\"\'%s\\n\'\"\'\"\'\ \"\$\{C\[@\]\}\"\ \|\ forkrun\ 2\>/dev/null\ "${runArgs}"\ "${fStr[$fInd]}"\'\;\ \}\ \|\ tee\ -a\ /tmp/.forkrun.log\;\ \)$'\n';) | ||
|
||
source <(printf '%s' \(\ \{\ diff\ 2\>/dev/null\ -q\ -B\ -E\ -Z\ -d\ -a\ -b\ -w\ \<\(printf\ \'%s\\x00\'\ \"\$\{C\[@\]\}\"\ \|\ forkrun\ 2\>/dev/null\ -z\ "${runArgs}"\ "${fStr[$fInd]}"\ "${fFix[$fInd]}"\ "${kFix[$kInd]}"\ \)\ \<\(printf\ \'%s\\n\'\ \"\$\{C\[@\]\}\"\ "${kFix[$kInd]}"\)\ \&\&\ printf\ \'%s\'\ \"PASS\"\ \|\|\ printf\ \'%s\'\ \"FAIL\"\;\ printf\ \'\:\ %s\\n\'\ \'printf\ \'\"\'\"\'%s\\0\'\"\'\"\'\ \"\$\{C\[@\]\}\"\ \|\ forkrun\ 2\>/dev/null\ -z\ "${runArgs}"\ "${fStr[$fInd]}"\'\;\ \}\ \|\ tee\ -a\ /tmp/.forkrun.log\;\ \)$'\n';) | ||
done | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters