mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
also migrate tests to meson
This commit is contained in:
@@ -6,7 +6,7 @@ labels:
|
|||||||
platform: ${platform}
|
platform: ${platform}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
build-berkeley:
|
build:
|
||||||
when:
|
when:
|
||||||
event: [push]
|
event: [push]
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
@@ -16,4 +16,14 @@ steps:
|
|||||||
- meson setup --reconfigure build
|
- meson setup --reconfigure build
|
||||||
- ninja -C build
|
- ninja -C build
|
||||||
|
|
||||||
|
test:
|
||||||
|
when:
|
||||||
|
event: [push]
|
||||||
|
image: alpine:latest
|
||||||
|
commands:
|
||||||
|
- apk update
|
||||||
|
- apk add --no-cache bash build-base gdb perl sodium sodium-dev jansson jansson-dev db db-dev pkgconfig meson ninja
|
||||||
|
- meson setup --reconfigure build
|
||||||
|
- ninja -C build test
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ steps:
|
|||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
commands:
|
commands:
|
||||||
- apk update
|
- apk update
|
||||||
- apk add --no-cache bash build-base words-en gdb perl pcre2-static pcre2-dev gdbm gdbm-dev pkgconfig meson ninja git
|
- apk add --no-cache bash build-base gdb perl sodium sodium-dev jansson jansson-dev db db-dev pkgconfig meson ninja
|
||||||
- meson setup --reconfigure --prefer-static -Dcpp_link_args="-static" --buildtype=release build
|
- meson setup --reconfigure --prefer-static -Dcpp_link_args="-static" --buildtype=release build
|
||||||
- ninja -C build
|
- ninja -C build
|
||||||
- meson dist -C build --formats xztar,gztar,zip
|
- meson dist -C build --formats xztar,gztar,zip
|
||||||
|
|||||||
@@ -115,3 +115,6 @@ if pod2man.found()
|
|||||||
install_man('pcp.1')
|
install_man('pcp.1')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
subdir('tests')
|
||||||
|
|||||||
@@ -20,17 +20,20 @@
|
|||||||
# You can contact me by mail: <tlinden AT cpan DOT org>.
|
# You can contact me by mail: <tlinden AT cpan DOT org>.
|
||||||
#
|
#
|
||||||
|
|
||||||
pcp=../src/pcp1
|
pcp=../pcp
|
||||||
vault=v1
|
vault=v1
|
||||||
passwd=xxx
|
passwd=xxx
|
||||||
md5msg=66b8c4ca9e5d2a7e3c0559c3cdea3d50
|
md5msg=66b8c4ca9e5d2a7e3c0559c3cdea3d50
|
||||||
|
os=$(uname)
|
||||||
|
|
||||||
. ./keys.cfg
|
. ./keys.cfg
|
||||||
|
|
||||||
check_dependencies_shell () {
|
check_dependencies_shell () {
|
||||||
cmd="which mdmfs"
|
if test "$os" = "FreeBSD"; then
|
||||||
expect="/mdmfs/"
|
cmd="which mdmfs"
|
||||||
check "$cmd" "$expect" "$input"
|
expect="/mdmfs/"
|
||||||
|
check "$cmd" "$expect" "$input"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_dependencies_pcp () {
|
check_dependencies_pcp () {
|
||||||
@@ -39,10 +42,16 @@ check_dependencies_pcp () {
|
|||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
# this one only works on freebsd for my user. sorrry
|
# this one only works on freebsd for my user. sorry
|
||||||
check_vault_disk_full () {
|
check_vault_disk_full () {
|
||||||
sudo mdmfs -s 1M -w 1001:1001 md env && dd if=/dev/zero of=env/b bs=1024 count=700
|
if test "$os" = "FreeBSD"; then
|
||||||
cmd="./jot 100 | while read N; do if ! (echo a; echo b) | $pcp -V env/v1 -k -x x; then break; fi; done"
|
sudo mdmfs -s 1M -w 1001:1001 md env && dd if=/dev/zero of=env/b bs=1024 count=700
|
||||||
expect="/Failed to copy/"
|
cmd="./jot 100 | while read N; do if ! (echo a; echo b) | $pcp -V env/v1 -k -x x; then break; fi; done"
|
||||||
check "$cmd" "$expect" "$input"
|
expect="/Failed to copy/"
|
||||||
|
check "$cmd" "$expect" "$input"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
# You can contact me by mail: <tlinden AT cpan DOT org>.
|
# You can contact me by mail: <tlinden AT cpan DOT org>.
|
||||||
#
|
#
|
||||||
|
|
||||||
pcp=../src/pcp1
|
pcp=../pcp
|
||||||
passwd=xxx
|
passwd=xxx
|
||||||
verbose=1
|
verbose=1
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
file=$1
|
file=$1
|
||||||
../src/pcp1 -C $file | awk '{print $4}'
|
../pcp -C $file | awk '{print $4}'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
54
tests/meson.build
Normal file
54
tests/meson.build
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# -*-python-*-
|
||||||
|
|
||||||
|
# genheader statictest buffertest sample pipetest decodertest
|
||||||
|
|
||||||
|
fs = import('fs')
|
||||||
|
|
||||||
|
binaries = [
|
||||||
|
'gencheader',
|
||||||
|
'statictest',
|
||||||
|
'buffertest',
|
||||||
|
'sample',
|
||||||
|
'pipetest',
|
||||||
|
'decodertest',
|
||||||
|
'mangle',
|
||||||
|
'invalidkeys',
|
||||||
|
'pwhashes',
|
||||||
|
'streamtest',
|
||||||
|
]
|
||||||
|
|
||||||
|
configs = [
|
||||||
|
'cppunittests.cfg',
|
||||||
|
'iotests.cfg',
|
||||||
|
'jsonunittests.cfg',
|
||||||
|
'keys.cfg',
|
||||||
|
'pyunittests.cfg',
|
||||||
|
'stresstests.cfg',
|
||||||
|
'unittests.cfg',
|
||||||
|
'md5',
|
||||||
|
'jot',
|
||||||
|
'bart.pub',
|
||||||
|
'key-alicia-pub',
|
||||||
|
'key-alicia-sec',
|
||||||
|
'key-bobby-pub',
|
||||||
|
'key-bobby-sec'
|
||||||
|
]
|
||||||
|
|
||||||
|
foreach binary: binaries
|
||||||
|
executable(
|
||||||
|
binary,
|
||||||
|
binary + '.c',
|
||||||
|
include_directories: [pcp_inc],
|
||||||
|
dependencies: [libpcp_dep, pcp_deps],
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
foreach config: configs
|
||||||
|
cp = fs.copyfile(config)
|
||||||
|
endforeach
|
||||||
|
|
||||||
|
unittest = find_program('unittests.sh', '.')
|
||||||
|
|
||||||
|
test('C tests', unittest, args : ['unittests.cfg'])
|
||||||
|
test('IO tests', unittest, args : ['iotests.cfg'])
|
||||||
|
test('JSON tests', unittest, args : ['jsonunittests.cfg'])
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
#include <unistd.h>
|
#include <limits.h>
|
||||||
|
#include <sodium.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sodium.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include "mem.h"
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "keyprint.h"
|
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
#include "keyprint.h"
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
struct _pw_t {
|
struct _pw_t {
|
||||||
char hash[65];
|
char hash[65];
|
||||||
@@ -24,28 +24,29 @@ int main() {
|
|||||||
pw *list = NULL;
|
pw *list = NULL;
|
||||||
pw *have = NULL;
|
pw *have = NULL;
|
||||||
unsigned char nonce[32] = {1};
|
unsigned char nonce[32] = {1};
|
||||||
|
PCPCTX *ptx = ptx_new();
|
||||||
|
|
||||||
if(sodium_init() == -1) return 1;
|
if (sodium_init() == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
for(i=97; i<126; ++i) {
|
for (i = 97; i < 126; ++i) {
|
||||||
pass[0] = i;
|
pass[0] = i;
|
||||||
pass[1] = 0;
|
pass[1] = 0;
|
||||||
h = pcp_derivekey(pass, nonce);
|
h = pcp_derivekey(ptx, pass, nonce);
|
||||||
|
|
||||||
p =0;
|
p = 0;
|
||||||
for(t=0; t<32; ++t) {
|
for (t = 0; t < 32; ++t) {
|
||||||
sprintf(&tmp[p], "%02x", h[t]);
|
sprintf(&tmp[p], "%02x", h[t]);
|
||||||
p += 2;
|
p += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
have = NULL;
|
have = NULL;
|
||||||
HASH_FIND_STR(list, tmp, have);
|
HASH_FIND_STR(list, tmp, have);
|
||||||
if(have == NULL) {
|
if (have == NULL) {
|
||||||
item = ucmalloc(sizeof(pw));
|
item = ucmalloc(sizeof(pw));
|
||||||
memcpy(item->hash, tmp, 65);
|
memcpy(item->hash, tmp, 65);
|
||||||
HASH_ADD_STR( list, hash, item );
|
HASH_ADD_STR(list, hash, item);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fprintf(stderr, "Error: collision found: %s!\n", have->hash);
|
fprintf(stderr, "Error: collision found: %s!\n", have->hash);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
# You can contact me by mail: <tlinden AT cpan DOT org>.
|
# You can contact me by mail: <tlinden AT cpan DOT org>.
|
||||||
#
|
#
|
||||||
|
|
||||||
pcp=../src/pcp1
|
pcp=../pcp
|
||||||
vault=v1
|
vault=v1
|
||||||
passwd=ech9xeiT%CuxuH1ch-is2ies1R
|
passwd=ech9xeiT%CuxuH1ch-is2ies1R
|
||||||
md5msg=66b8c4ca9e5d2a7e3c0559c3cdea3d50
|
md5msg=66b8c4ca9e5d2a7e3c0559c3cdea3d50
|
||||||
@@ -40,29 +40,29 @@ check_dependencies_pcp () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_streams_8 () {
|
check_streams_8 () {
|
||||||
md5=`./md5 ../COPYING`
|
md5=`./md5 ../../COPYING`
|
||||||
cmd="./pipetest 8 e < ../COPYING | ./pipetest 8 d | ./md5"
|
cmd="./pipetest 8 e < ../../COPYING | ./pipetest 8 d | ./md5"
|
||||||
expect="/$md5/"
|
expect="/$md5/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_streams_16 () {
|
check_streams_16 () {
|
||||||
md5=`./md5 ../COPYING`
|
md5=`./md5 ../../COPYING`
|
||||||
cmd="./pipetest 16 e < ../COPYING | ./pipetest 16 d | ./md5"
|
cmd="./pipetest 16 e < ../../COPYING | ./pipetest 16 d | ./md5"
|
||||||
expect="/$md5/"
|
expect="/$md5/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_streams_32 () {
|
check_streams_32 () {
|
||||||
md5=`./md5 ../COPYING`
|
md5=`./md5 ../../COPYING`
|
||||||
cmd="./pipetest 32 e < ../COPYING | ./pipetest 32 d | ./md5"
|
cmd="./pipetest 32 e < ../../COPYING | ./pipetest 32 d | ./md5"
|
||||||
expect="/$md5/"
|
expect="/$md5/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_streams_64 () {
|
check_streams_64 () {
|
||||||
md5=`./md5 ../COPYING`
|
md5=`./md5 ../../COPYING`
|
||||||
cmd="./pipetest 64 e < ../COPYING | ./pipetest 64 d | ./md5"
|
cmd="./pipetest 64 e < ../../COPYING | ./pipetest 64 d | ./md5"
|
||||||
expect="/$md5/"
|
expect="/$md5/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
@@ -284,27 +284,27 @@ check_sym_decrypt () {
|
|||||||
#
|
#
|
||||||
# signature tests
|
# signature tests
|
||||||
check_sign_detached_to_bobby () {
|
check_sign_detached_to_bobby () {
|
||||||
cmd="$pcp -V va -g -I README -f testsig -x a"
|
cmd="$pcp -V va -g -I ../../COPYING -f testsig -x a"
|
||||||
expectfile="testsig"
|
expectfile="testsig"
|
||||||
expect=""
|
expect=""
|
||||||
check "$cmd" "$expect" "$input" "$expectfile"
|
check "$cmd" "$expect" "$input" "$expectfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_verify_detached_signature () {
|
check_verify_detached_signature () {
|
||||||
cmd="$pcp -V vb -c -f testsig -I README -i $idalicia"
|
cmd="$pcp -V vb -c -f testsig -I ../../COPYING -i $idalicia"
|
||||||
expect="/verified/"
|
expect="/verified/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_verify_detached_signature_self () {
|
check_verify_detached_signature_self () {
|
||||||
cmd="$pcp -V va -c -f testsig -I README"
|
cmd="$pcp -V va -c -f testsig -I ../../COPYING"
|
||||||
expect="/verified/"
|
expect="/verified/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_sign_armored_to_bobby () {
|
check_sign_armored_to_bobby () {
|
||||||
rm -f testsig
|
rm -f testsig
|
||||||
cmd="$pcp -V va -g -I README -O testsig -x a -z"
|
cmd="$pcp -V va -g -I ../../COPYING -O testsig -x a -z"
|
||||||
expectfile="testsig"
|
expectfile="testsig"
|
||||||
expect=""
|
expect=""
|
||||||
check "$cmd" "$expect" "$input" "$expectfile"
|
check "$cmd" "$expect" "$input" "$expectfile"
|
||||||
@@ -324,7 +324,7 @@ check_verify_armored_signature_self () {
|
|||||||
|
|
||||||
check_sign_bin_to_bobby () {
|
check_sign_bin_to_bobby () {
|
||||||
rm -f testsig
|
rm -f testsig
|
||||||
cmd="$pcp -V va -g -I README -O testsig -x a"
|
cmd="$pcp -V va -g -I ../../COPYING -O testsig -x a"
|
||||||
expectfile="testsig"
|
expectfile="testsig"
|
||||||
expect=""
|
expect=""
|
||||||
check "$cmd" "$expect" "$input" "$expectfile"
|
check "$cmd" "$expect" "$input" "$expectfile"
|
||||||
@@ -345,7 +345,7 @@ check_verify_bin_signature_self () {
|
|||||||
#
|
#
|
||||||
# sign+encrypt tests
|
# sign+encrypt tests
|
||||||
check_sign_crypt_to_bobby () {
|
check_sign_crypt_to_bobby () {
|
||||||
cmd="$pcp -V va -g -e -I README -O testsig -r Bobby -x a"
|
cmd="$pcp -V va -g -e -I ../../COPYING -O testsig -r Bobby -x a"
|
||||||
expect="/Encrypted/"
|
expect="/Encrypted/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
@@ -572,26 +572,26 @@ check_fuzz_binary_seckey () {
|
|||||||
|
|
||||||
# checksum tests
|
# checksum tests
|
||||||
check_checksum_copying () {
|
check_checksum_copying () {
|
||||||
cmd="$pcp -C ../COPYING"
|
cmd="$pcp -C ../../COPYING"
|
||||||
expect="/$blake2/"
|
expect="/$blake2/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_checksum_authenticated_copying () {
|
check_checksum_authenticated_copying () {
|
||||||
cmd="$pcp -x $key -C ../COPYING"
|
cmd="$pcp -x $key -C ../../COPYING"
|
||||||
expect="/$blake2auth/"
|
expect="/$blake2auth/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_checksum_copying_stdin () {
|
check_checksum_copying_stdin () {
|
||||||
cmd="$pcp -C < ../COPYING"
|
cmd="$pcp -C < ../../COPYING"
|
||||||
expect="/$blake2/"
|
expect="/$blake2/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_checksum_multiple () {
|
check_checksum_multiple () {
|
||||||
cmd="$pcp -C ../COPYING ../README"
|
cmd="$pcp -C ../../COPYING ../../../COPYING"
|
||||||
expect="/README/"
|
expect="/../../COPYING/"
|
||||||
check "$cmd" "$expect" "$input"
|
check "$cmd" "$expect" "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,13 +106,23 @@ callcheck () {
|
|||||||
cfg="$1"
|
cfg="$1"
|
||||||
check="$2"
|
check="$2"
|
||||||
|
|
||||||
|
pwd=$(pwd)
|
||||||
|
base=$(basename "$pwd")
|
||||||
|
|
||||||
|
if test "$base" != "test"; then
|
||||||
|
cd tests
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "PWD: $(pwd)"
|
||||||
|
|
||||||
if test -z "$cfg"; then
|
if test -z "$cfg"; then
|
||||||
echo "Usage: $0 <config> [check]"
|
echo "Usage: $0 <config> [check]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -e "$cfg"; then
|
if ! test -e "$cfg"; then
|
||||||
echo "$cfg doesn't exist!"
|
echo "$cfg doesn't exist ($(pwd))!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user