move from bashunit to shunit2. refactoring tests. (#272)

* move from bashunit to shunit2

move run-tests.sh to test

simplify build.yml

* back shunit2 to submodule
This commit is contained in:
Alexandr Reshetnikov
2022-06-11 12:52:34 +04:00
committed by GitHub
parent 3082ba9bed
commit a4f40a21ae
21 changed files with 294 additions and 273 deletions

View File

@@ -7,102 +7,84 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
container: 'ubuntu:latest'
artifact: 'ubuntu'
- os: ubuntu-latest
container: 'alpine:latest'
artifact: 'alpine'
- os: windows-latest
artifact: 'windows'
- os: macos-latest
artifact: 'macos'
container: ${{ matrix.container }}
steps:
- name: Install Ubuntu packages
if: runner.os == 'Linux'
run: sudo env DEBIAN_FRONTEND=noninteractive apt-get -qq -y install pbzip2 zstd
if: matrix.container == 'ubuntu:latest'
run: |
apt update
apt -y install git make pbzip2 binutils bzip2 zstd gnupg
- name: Install Alpine packages
if: matrix.container == 'alpine:latest'
run: apk add --no-cache bash git make libarchive-tools gnupg coreutils binutils bzip2 zstd
- name: Install macOS packages
if: runner.os == 'macOS'
run: brew install pbzip2 coreutils zstd
- name: Checkout Makeself
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Build release
run: make
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
with:
name: Makeself-Build-${{ runner.os }}
name: build-${{ matrix.artifact }}
path: release
- name: Run tests
run: make test
test-make-alpine:
runs-on: ubuntu-latest
container: alpine:latest
steps:
- name: install deps
run: apk add --no-cache bash git make libarchive-tools gnupg coreutils
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Run tests
run: make test
test-freebsd:
needs: test
runs-on: macos-10.15
name: Test Makeself on FreeBSD
steps:
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Linux
path: linux
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-macOS
path: mac
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Windows
path: windows
- name: Test on FreeBSD
uses: vmactions/freebsd-vm@v0.1.5
with:
usesh: true
prepare: pkg install -y pbzip2
run: |
pwd; freebsd-version
sh ./linux/makeself*.run --target /tmp/makeself-linux
sh ./mac/makeself*.run --target /tmp/makeself-mac
sh ./windows/makeself*.run --target /tmp/makeself-windows
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Test on FreeBSD
uses: vmactions/freebsd-vm@v0.1.5
with:
usesh: true
prepare: pkg install -y pbzip2
run: |
pwd; freebsd-version
sh ./test/run-makeself.sh
test-solaris:
needs: test
runs-on: macos-10.15
name: Test Makeself on Solaris
steps:
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Linux
path: linux
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-macOS
path: mac
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Windows
path: windows
- name: Test on Solaris
uses: vmactions/solaris-vm@v0.0.3
with:
mem: 2048
prepare: pkgutil -y -i pbzip2
run: |
pwd
sh ./linux/makeself*.run --target /tmp/makeself-linux
sh ./mac/makeself*.run --target /tmp/makeself-mac
sh ./windows/makeself*.run --target /tmp/makeself-windows
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Test on Solaris
uses: vmactions/solaris-vm@v0.0.3
with:
mem: 2048
prepare: pkgutil -y -i pbzip2
run: |
pwd
sh ./test/run-makeself.sh
test-alpine:
needs: test
@@ -110,23 +92,10 @@ jobs:
runs-on: ubuntu-latest
container: alpine:latest
steps:
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Linux
path: linux
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-macOS
path: mac
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Windows
path: windows
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Test on Alpine
run: |
sh ./linux/makeself*.run --target /tmp/makeself-linux
sh ./mac/makeself*.run --target /tmp/makeself-mac
sh ./windows/makeself*.run --target /tmp/makeself-windows
run: sh ./test/run-makeself.sh
test-nanoserver:
needs: test
@@ -136,18 +105,8 @@ jobs:
IMAGE_NAME: mcr.microsoft.com/windows/nanoserver:ltsc2022-amd64
steps:
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Linux
path: linux
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-macOS
path: mac
- uses: actions/download-artifact@v2
with:
name: Makeself-Build-Windows
path: windows
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: pull windows container ${{ env.IMAGE_NAME }}
shell: cmd
@@ -155,14 +114,13 @@ jobs:
docker pull ${{ env.IMAGE_NAME }}
docker images ${{ env.IMAGE_NAME }}
- name: download tools
shell: cmd
run: curl --fail --silent --show-error --remote-name --location "https://frippery.org/files/busybox/busybox64.exe"
- name: Test on Nanoserver
shell: cmd
run: >
docker container run --rm --env CI=true -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }}
curl --fail --silent --show-error --remote-name --location "https://frippery.org/files/busybox/busybox64.exe" &&
busybox64 sh .\linux\makeself*.run --target \tmp\makeself-linux &&
busybox64 sh .\mac\makeself*.run --target \tmp\makeself-mac &&
busybox64 sh .\windows\makeself*.run --target \tmp\makeself-windows
run: docker container run --rm --env CI=true -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\busybox64.exe sh ./test/run-makeself.sh
lint:
runs-on: ubuntu-latest

6
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "test/bashunit"]
path = test/bashunit
url = https://github.com/djui/bashunit.git
[submodule "test/shunit2"]
path = test/shunit2
url = https://github.com/kward/shunit2

View File

@@ -12,7 +12,7 @@ clean:
$(RM) makeself-*.run
test:
./run-tests.sh
./test/run-tests.sh
help:
$(info Targets: all $(OUTPUT) clean test help)

View File

@@ -1,11 +0,0 @@
#!/bin/sh
# Run every available test - Bash needed
THISDIR="$(realpath "$(dirname "$0")")"
cd "$THISDIR/test"
for test in *test;
do
echo "Running test $test ..."
bash "$test" || { echo "*** ERROR: Test '$test' failed!"; exit 1; }
done

31
test/appendtest Executable file → Normal file
View File

@@ -1,13 +1,13 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
SUT="${SRCDIR}/makeself.sh"
WHAT="$(basename "${THIS}")"
# FIXME: These tests need to check that the concatenation of archives works
set -eu
THIS="$(realpath "$0")"
WHAT="$(basename "${THIS}")"
HERE="$(dirname "${THIS}")"
SRCDIR="$(dirname "${HERE}")"
SUT="${SRCDIR}/makeself.sh"
readonly archive_dir_create="$(mktemp -dt archive_dir_create.XXXXXX)"
readonly archive_dir_append="$(mktemp -dt archive_dir_append.XXXXXX)"
@@ -18,7 +18,7 @@ touch "${archive_dir_append}/fum"
evalAssert() {
eval "$@"
assertEqual "$?" "0"
assertEquals "$?" "0"
}
# $1 : file_name
@@ -31,7 +31,7 @@ doInfoListCheckExec() {
# $1 : file_name
# rest : content basenames
assertContains() {
assertFileContains() {
local file_name=""
file_name="$(realpath "$1")"
shift
@@ -39,9 +39,7 @@ assertContains() {
rm -rf "${target}"
mkdir -p "${target}"
evalAssert "${file_name}" --target "${target}"
assertEqual \
"$(find "${target}" -type f -exec basename -a {} + | sort)" \
"$(echo "$@" | sort)"
assertEquals "$(find "${target}" -type f -exec basename -a {} + | sort)" "$(echo -e "$@" | sort)"
rm -rf "${target}"
}
@@ -59,13 +57,13 @@ doTestOpts() {
"echo ${stem}"
file_name="$(realpath ${file_name})"
doInfoListCheckExec "${file_name}"
assertContains "${file_name}" "fee" "fie"
assertFileContains "${file_name}" "fee\nfie"
evalAssert "${SUT}" "$@" --sha256 \
--append "${archive_dir_append}" \
"${file_name}"
doInfoListCheckExec "${file_name}"
assertContains "${file_name}" "fee" "fie" "foe" "fum"
assertFileContains "${file_name}" "fee\nfie\nfoe\nfum"
rm -f "${file_name}"
}
@@ -96,6 +94,5 @@ testPigz() { doTestComp --pigz; }
testXz() { doTestComp --xz; }
testZstd() { doTestComp --zstd; }
source bashunit/bashunit.bash
rm -rf "${archive_dir_create}" "${archive_dir_append}"
# Load and run shUnit2.
source "./shunit2/shunit2"

Submodule test/bashunit deleted from deacbc8141

31
test/corrupttest Executable file → Normal file
View File

@@ -1,38 +1,45 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
SUT="${SRCDIR}/makeself.sh"
# Test that corrupted archives actually fail validation
SUT=$(realpath $(dirname $0)/../makeself.sh)
SOURCE=$(realpath ..)
cd "$THISDIR"
setupTests() {
temp=`mktemp -d -t appendtest.XXXXX`
cd "$temp"
mkdir archive
cp -a $SOURCE archive/
$SUT $* archive makeself-test.run "Test $*" echo Testing --tar-extra="--exclude .git"
temp_path="$(mktemp -dt appendtest.XXXXXX)"
cd "$temp_path"
mkdir -p archive
cp -a "$SRCDIR" archive/
"$SUT" "$*" archive makeself-test.run "Test $*" echo Testing --tar-extra="--exclude .git"
}
testExtraBytes() {
setupTests --sha256
./makeself-test.run --check
assertEqual $? 0
assertEquals $? 0
echo "Adding a bunch of random characters at the end!!" >> makeself-test.run
./makeself-test.run --check
assertNotEqual $? 0
assertNotEquals $? 0
}
testTruncated() {
setupTests --sha256
./makeself-test.run --check
assertEqual $? 0
assertEquals $? 0
dd if=makeself-test.run of=truncated.run bs=1 count=34303
bash truncated.run --check
assertNotEqual $? 0
assertNotEquals $? 0
}
source bashunit/bashunit.bash
# Load and run shUnit2.
source "./shunit2/shunit2"

63
test/datetest Executable file → Normal file
View File

@@ -1,19 +1,26 @@
#!/bin/bash
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
SUT="${SRCDIR}/makeself.sh"
SUT=$(realpath $(dirname $0)/../makeself.sh)
setupTests() {
temp=`mktemp -d -t XXXXX`
cd ${temp}
setUp() {
temp="$(mktemp -dt datetest.XXXXX)"
cd "${temp}"
mkdir src
echo "echo This is a test" > src/startup.sh
}
tearDown() {
# Cleanup
cd -
rm -rf "${temp}"
}
# Default behaviour is to insert the current date in the
# generated file.
testCurrentDate() {
setupTests
${SUT} src src.sh alabel startup.sh
# Validate
@@ -28,11 +35,7 @@ testCurrentDate() {
echo "Substring not found: ${expected} in ${actual}"
found=1
fi
assertEqual 0 ${found}
# Cleanup
cd -
rm -rf ${temp}
assertEquals 0 ${found}
}
@@ -42,8 +45,6 @@ testCurrentDate() {
# source and remain byte-for-bye
# identical.
testDateSet() {
setupTests
expected='Sat Mar 5 19:35:21 EST 2016'
# Exercise
@@ -61,19 +62,13 @@ testDateSet() {
echo "Substring not found: ${expected} in ${actual}"
found=1
fi
assertEqual 0 ${found}
# Cleanup
cd -
rm -rf ${temp}
assertEquals 0 ${found}
}
# Error if --packaging-date is passed as
# an argument but the date is missing
testPackagingDateNeedsParameter() {
setupTests
# Exercise
${SUT} --packaging-date \
src src.sh alabel startup.sh || true
@@ -81,21 +76,20 @@ testPackagingDateNeedsParameter() {
# Validate
echo "actual="${actual}
assertNotEqual 0 ${actual}
# Cleanup
cd -
rm -rf ${temp}
assertNotEquals 0 "${actual}"
}
# With the dates set we can get a byte for
# byte identical package.
testByteforbyte()
{
setupTests
date='Sat Mar 3 19:35:21 EST 2016'
# bsdtar does not have option --mtime
# TODO: unstable test: first second differ: char 242, line 10
startSkipping
# Exercise
${SUT} --packaging-date "${date}" --tar-extra "--mtime 20160303" \
src src.sh alabel startup.sh
@@ -106,12 +100,9 @@ testByteforbyte()
# Validate
cmp first second
rc=$?
assert $rc
# Cleanup
cd -
rm -rf ${temp}
assertEquals $? 0
}
source bashunit/bashunit.bash
# Load and run shUnit2.
source "./shunit2/shunit2"

29
test/extracttest Executable file → Normal file
View File

@@ -1,14 +1,16 @@
#!/bin/bash
SUT=$(realpath $(dirname $0)/../makeself.sh)
SOURCE=$(realpath ..)
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
SUT="${SRCDIR}/makeself.sh"
setupTests() {
temp=`mktemp -d -t XXXXX`
cd "$temp"
mkdir archive
cp -a $SOURCE archive/
$SUT $* archive makeself-test.run "Test $*" echo Testing
cp -a "$SRCDIR" archive/
$SUT $* archive makeself-test.run "Test $*" echo Testing --tar-extra="--exclude .git"
}
@@ -17,7 +19,7 @@ testQuiet()
setupTests
./makeself-test.run --quiet
assertEqual $? 0
assertEquals $? 0
}
testGzip()
@@ -25,7 +27,7 @@ testGzip()
setupTests --gzip
./makeself-test.run --check
assertEqual $? 0
assertEquals $? 0
}
testBzip2()
@@ -33,28 +35,29 @@ testBzip2()
setupTests --bzip2
./makeself-test.run --check
assertEqual $? 0
assertEquals $? 0
}
testPBzip2()
{
# Skip if pbzip2 is not available
which pbzip2 || return
which pbzip2 || startSkipping
setupTests --pbzip2
./makeself-test.run --check
assertEqual $? 0
assertEquals $? 0
}
testZstd()
{
# Skip if zstd is not available
which zstd || return
which zstd || startSkipping
setupTests --zstd
./makeself-test.run --check
assertEqual $? 0
assertEquals $? 0
}
source bashunit/bashunit.bash
# Load and run shUnit2.
source "./shunit2/shunit2"

33
test/infotest Executable file → Normal file
View File

@@ -1,11 +1,13 @@
#!/bin/bash
# makeself/test/infotest
set -eu
THIS="$(realpath "$0")"
HERE="$(dirname "${THIS}")"
SRCDIR="$(dirname "${HERE}")"
VERSION="$(xargs printf '%s' <"${SRCDIR}/VERSION")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
VERSION="$(cat "${SRCDIR}/VERSION")"
is_alpine_distro=false && [[ -f "/etc/alpine-release" ]] && is_alpine_distro=true
uncompressed_size="12 KB" && [[ $is_alpine_distro == true ]] && uncompressed_size="4 KB"
################################################################################
@@ -16,9 +18,9 @@ haveInfo() (
cd "${SRCDIR}" || return 1
mkdir -p infotest
./makeself.sh "$@" ./infotest ./infotest.run infotest ls -lah >/dev/null 2>&1
assertEqual "$?" 0 >&2
assertEquals "$?" 0 >&2
./infotest.run --info
assertEqual "$?" 0 >&2
assertEquals "$?" 0 >&2
rm -rf infotest infotest.run
)
@@ -45,7 +47,7 @@ testDefault() (
diffInfo --packaging-date "@0" <<EOF
Identification: infotest
Target directory: infotest
Uncompressed size: 12 KB
Uncompressed size: $uncompressed_size
Compression: gzip
Encryption: n
Date of packaging: @0
@@ -62,7 +64,7 @@ Script run after extraction:
ls -lah
infotest will be removed after extraction
EOF
assertEqual "$?" 0
assertEquals "$?" 0
)
testNocomp() (
@@ -70,7 +72,7 @@ testNocomp() (
diffInfo --packaging-date "@0" --nocomp <<EOF
Identification: infotest
Target directory: infotest
Uncompressed size: 12 KB
Uncompressed size: $uncompressed_size
Compression: none
Encryption: n
Date of packaging: @0
@@ -88,7 +90,7 @@ Script run after extraction:
ls -lah
infotest will be removed after extraction
EOF
assertEqual "$?" 0
assertEquals "$?" 0
)
testNotemp() (
@@ -96,7 +98,7 @@ testNotemp() (
diffInfo --packaging-date "@0" --notemp <<EOF
Identification: infotest
Target directory: infotest
Uncompressed size: 12 KB
Uncompressed size: $uncompressed_size
Compression: gzip
Encryption: n
Date of packaging: @0
@@ -114,9 +116,10 @@ Script run after extraction:
ls -lah
directory infotest is permanent
EOF
assertEqual "$?" 0
assertEquals "$?" 0
)
################################################################################
source "${HERE}/bashunit/bashunit.bash"
# Load and run shUnit2.
source "./shunit2/shunit2"

16
test/lsmtest Executable file → Normal file
View File

@@ -1,12 +1,8 @@
#!/bin/bash
# makeself/test/lsmtest
set -eu
THIS="$(realpath "$0")"
HERE="$(dirname "${THIS}")"
SRCDIR="$(dirname "${HERE}")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
################################################################################
@@ -17,9 +13,9 @@ withlsm() (
cd "${SRCDIR}"
mkdir -p lsmtest
./makeself.sh "$@" ./lsmtest ./lsmtest.run lsmtest ls -lah >/dev/null 2>&1
assertEqual "$?" 0 >&2
assertEquals "$?" 0 >&2
./lsmtest.run --lsm
assertEqual "$?" 0 >&2
assertEquals "$?" 0 >&2
rm -rf lsmtest lsmtest.run
)
@@ -44,5 +40,5 @@ test_lsm_one_line_without_nl() {
################################################################################
# shellcheck disable=SC1091
source "${HERE}/bashunit/bashunit.bash"
# Load and run shUnit2.
source "./shunit2/shunit2"

18
test/run-makeself.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
VERSION="$(cat "${SRCDIR}/VERSION")"
# Test run on artifacts
echo ">> env:"
uname -a
cd "$THISDIR"
sh "../build-ubuntu/makeself-$VERSION.run" --target ./tmp/makeself-ubuntu
sh "../build-alpine/makeself-$VERSION.run" --target ./tmp/makeself-alpine
sh "../build-windows/makeself-$VERSION.run" --target ./tmp/makeself-windows
sh "../build-macos/makeself-$VERSION.run" --target ./tmp/makeself-macos

32
test/run-testlinter.sh Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
cd "$THISDIR"
is_windows_os=false
[[ $(uname) == Windows_NT* ]] && is_windows_os=true
[[ $(uname) == MINGW64_NT* ]] && is_windows_os=true
testShStartsWith() {
if [[ $is_windows_os == true ]]; then
return
fi
for test_sh in ./*test; do
file_name="$(basename -- "$test_sh")"
if [[ -f "${test_sh}" ]]; then
echo ">> Test $file_name"
local etalon_head="$(printf '#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
')"
assertEquals "$etalon_head" "$(cat "${test_sh}" | head -4)"
fi
done
}
# Load and run shUnit2.
source "./shunit2/shunit2"

20
test/run-tests.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
# Run every available test
echo ">> env:"
uname -a
cd "$THISDIR"
bash "./run-testlinter.sh"
for test in ./*test;
do
echo "::group::$test"
bash "./$test" || { echo "*** ERROR: Test '$test' failed!"; exit 1; }
echo "::endgroup::"
done

1
test/shunit2 Submodule

Submodule test/shunit2 added at 47be8b23a4

46
test/signtest Executable file → Normal file
View File

@@ -1,10 +1,8 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
HERE="$(dirname "${THIS}")"
SUT="$(dirname "${HERE}")/makeself.sh"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
################################################################################
@@ -147,9 +145,9 @@ EOF
checked_import_key() {
cat_key "$1" \
| gpg --quiet --import --passphrase=password123 --pinentry-mode=loopback --trust-model=always
assertEqual "$?" 0
assertEquals "$?" 0
gpg --list-secret-keys "$1" >/dev/null 2>&1
assertEqual "$?" 0
assertEquals "$?" 0
}
# $1 : keyid
@@ -173,11 +171,11 @@ create_sign_verify() {
"${SUT}" --sign password123 "$@" \
"${archive_dir}" "${archive_run}" "signtest" ls \
>"${output}"
assertEqual "$?" 0
assertEquals "$?" 0
# check output for signature
grep -Exq 'Signature: [[:alnum:]+/]+' "${output}"
assertEqual "$?" 0
assertEquals "$?" 0
# verify signature
local res=""
@@ -197,10 +195,10 @@ testSingleKey() (
export GNUPGHOME
checked_import_key 3DD6797A5EDE9A253311C13AED3E040B19F6996E
assertEqual "$?" 0
assertEquals "$?" 0
create_sign_verify 3DD6797A5EDE9A253311C13AED3E040B19F6996E
assertEqual "$?" 0
assertEquals "$?" 0
rm -rf "${GNUPGHOME}"
)
@@ -210,20 +208,20 @@ testMultipleKeys() (
export GNUPGHOME
checked_import_key 3DD6797A5EDE9A253311C13AED3E040B19F6996E
assertEqual "$?" 0
assertEquals "$?" 0
checked_import_key 3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1
assertEqual "$?" 0
assertEquals "$?" 0
create_sign_verify \
3DD6797A5EDE9A253311C13AED3E040B19F6996E \
--gpg-extra "--local-user=3DD6797A5EDE9A253311C13AED3E040B19F6996E"
assertEqual "$?" 0
assertEquals "$?" 0
create_sign_verify \
3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1 \
--gpg-extra "--local-user=3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1"
assertEqual "$?" 0
assertEquals "$?" 0
rm -rf "${GNUPGHOME}"
)
@@ -233,20 +231,20 @@ testWrongKey() (
export GNUPGHOME
checked_import_key 3DD6797A5EDE9A253311C13AED3E040B19F6996E
assertEqual "$?" 0
assertEquals "$?" 0
checked_import_key 3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1
assertEqual "$?" 0
assertEquals "$?" 0
create_sign_verify \
3DD6797A5EDE9A253311C13AED3E040B19F6996E \
--gpg-extra "--local-user=3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1" \
|| assertEqual "$?" 2
|| assertEquals "$?" 2
create_sign_verify \
3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1 \
--gpg-extra "--local-user=3DD6797A5EDE9A253311C13AED3E040B19F6996E" \
|| assertEqual "$?" 2
|| assertEquals "$?" 2
rm -rf "${GNUPGHOME}"
)
@@ -256,10 +254,10 @@ testWrongPassword() (
export GNUPGHOME
checked_import_key 3DD6797A5EDE9A253311C13AED3E040B19F6996E
assertEqual "$?" 0
assertEquals "$?" 0
checked_import_key 3F717988DF7D8D55A1660FC1A5ECF255B5AE77E1
assertEqual "$?" 0
assertEquals "$?" 0
# prepare archive directory
local archive_dir=""
@@ -276,15 +274,15 @@ testWrongPassword() (
"${SUT}" --sign TheWrongPassword1357 "$@" \
"${archive_dir}" "${archive_run}" "signtest" ls \
>"${output}"
assertEqual "$?" 0
assertEquals "$?" 0
grep -Fxq 'Signature: ' "${output}"
assertEqual "$?" 0
assertEquals "$?" 0
rm -rf "${GNUPGHOME}" "${archive_dir}" "${archive_run}" "${output}"
)
################################################################################
# shellcheck disable=SC1091
source "${HERE}/bashunit/bashunit.bash"
# Load and run shUnit2.
source "./shunit2/shunit2"

16
test/suidtest Executable file → Normal file
View File

@@ -1,8 +1,8 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
HERE="$(dirname "${THIS}")"
SUT="$(dirname "${HERE}")/makeself.sh"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
testSuidDoesntGetBroken() {
# Create a directory with a file on it
@@ -14,7 +14,7 @@ testSuidDoesntGetBroken() {
# Create the self extracting that should extract deployedfile
local file_name="$(mktemp -t file_name.XXXXXX)"
"${SUT}" --target "${archive_dir}" "${archive_dir}" "${file_name}" "suid test"
assertEqual $? 0
assertEquals $? 0
# Target directory now has another file with sudo permissions
# This will get broken because of chown -R
(
@@ -26,11 +26,13 @@ testSuidDoesntGetBroken() {
# We extract deployedfile, in hopes that it will not reset suid bit
# from suidfile.bin
"${file_name}"
assertEqual $? 0
assertEquals $? 0
permissionsAfter=$(stat -c %A "${archive_dir}"/suidfile.bin)
# And we check that permissions match
assertEqual "${permissionsBefore}" "${permissionsAfter}"
assertEquals "${permissionsBefore}" "${permissionsAfter}"
rm -rf "${archive_dir}" "${file_name}"
}
source "${HERE}/bashunit/bashunit.bash"
# Load and run shUnit2.
source "./shunit2/shunit2"

12
test/tarextratest Executable file → Normal file
View File

@@ -1,6 +1,8 @@
#!/bin/bash
SUT=$(realpath "$(dirname "$0")/../makeself.sh")
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
setupTests() {
temp=$(mktemp -d -t XXXXX)
@@ -20,9 +22,11 @@ testTarExtraOpts() {
tar_extra="--verbose --exclude .git"
${SUT} --tar-extra "$tar_extra" src src.sh alabel startup.sh
assertEqual $? 0
assertEquals $? 0
tearDown
}
source bashunit/bashunit.bash
# Load and run shUnit2.
source "./shunit2/shunit2"

19
test/variabletest Executable file → Normal file
View File

@@ -1,7 +1,8 @@
#!/usr/bin/env bash
SUT=$(realpath $(dirname $0)/../makeself.sh)
SOURCE=$(realpath ..)
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
setupTests() {
temp=`mktemp -d -t XXXXX`
@@ -21,7 +22,7 @@ testArchiveDir()
mv ./makeself-test.run "${ans}/"
actual_archive_dir="$("${ans}/makeself-test.run" --quiet)"
assertEqual "${actual_archive_dir}" "${ans}"
assertEquals "${actual_archive_dir}" "${ans}"
}
testTmpRoot()
@@ -32,7 +33,7 @@ testTmpRoot()
actual_tmp_root="$(TMPDIR="${ans}" "./makeself-test.run" --quiet)"
assertEqual "${actual_tmp_root}" "${ans}"
assertEquals "${actual_tmp_root}" "${ans}"
}
testUserPWD()
@@ -44,8 +45,8 @@ testUserPWD()
actual_user_pwd="$("${temp}/makeself-test.run" --quiet)"
assertEqual "${actual_user_pwd}" "${ans}"
assertEquals "${actual_user_pwd}" "${ans}"
}
source bashunit/bashunit.bash
# Load and run shUnit2.
source "./shunit2/shunit2"

15
test/whitespacelicensetest Executable file → Normal file
View File

@@ -1,8 +1,8 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
HERE="$(dirname "${THIS}")"
SUT="$(dirname "${HERE}")/makeself.sh"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
testWhiteSpaceLicense() {
# for each license file: its canonical path is identical to its content
@@ -44,20 +44,21 @@ EOF
"${file_name}" \
"Label" \
ls -lah
assertEqual "$?" 0
assertEquals "$?" 0
# Assumes the license text is the first line of output
license_text="$("${file_name}" --accept --nox11 | head -n1)"
# This doesn't work for character tabulation...
#assertEqual "${license_text}" "${license_file}"
#assertEquals "${license_text}" "${license_file}"
# ...so do this instead:
assertEqual \
assertEquals \
"$(cat "${license_file}" | md5sum | cut -d' ' -f1)" \
"$(echo "${license_text}" | md5sum | cut -d' ' -f1)"
done
rm -rf "${license_dir}" "${archive_dir}" "${file_name}"
}
source "${HERE}/bashunit/bashunit.bash"
# Load and run shUnit2.
source "./shunit2/shunit2"

11
test/whitespacetest Executable file → Normal file
View File

@@ -1,8 +1,8 @@
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
HERE="$(dirname "${THIS}")"
SUT="$(dirname "${HERE}")/makeself.sh"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
testWhiteSpace() {
local archive_dir="$(mktemp -dt archive_dir.XXXXXX)"
@@ -16,8 +16,9 @@ testWhiteSpace() {
)
local file_name="$(mktemp -t file_name.XXXXXX)"
"${SUT}" "${archive_dir}" "${file_name}" "white space test" "ls -lah ."
assertEqual $? 0
assertEquals $? 0
rm -rf "${archive_dir}" "${file_name}"
}
source "${HERE}/bashunit/bashunit.bash"
# Load and run shUnit2.
source "./shunit2/shunit2"