mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 03:50:57 +01:00
(back) ported win32 32bit compatibility along with lots of fixes
This commit is contained in:
4
tests/collisions.c
Normal file → Executable file
4
tests/collisions.c
Normal file → Executable file
@@ -26,7 +26,7 @@
|
||||
|
||||
unsigned djb_hash ( void *key, int len ) {
|
||||
unsigned char *p = key;
|
||||
unsigned h = 0;
|
||||
unsigned h = 0U;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
@@ -37,7 +37,7 @@ unsigned djb_hash ( void *key, int len ) {
|
||||
|
||||
unsigned fnv_hash ( void *key, int len ) {
|
||||
unsigned char *p = key;
|
||||
unsigned h = 2166136261;
|
||||
unsigned h = 2166136261U;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
|
||||
5
tests/cpptest.cpp
Normal file → Executable file
5
tests/cpptest.cpp
Normal file → Executable file
@@ -60,8 +60,9 @@ void test0() {
|
||||
|
||||
DECRYPTED = _openrd("testcppdecrypted");
|
||||
char *got = (char *)ucmalloc(10);
|
||||
size_t h;
|
||||
h = fread(got, 1, 6, DECRYPTED);
|
||||
if(fread(got, 1, 6, DECRYPTED) < 6) {
|
||||
throw pcp::exception("read error, could not read decrypted content");
|
||||
}
|
||||
if(strncmp(got, "HALLO", 5) != 0) {
|
||||
throw pcp::exception();
|
||||
}
|
||||
|
||||
4
tests/gencheader.c
Normal file → Executable file
4
tests/gencheader.c
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
#include <pcp.h>
|
||||
|
||||
void pr(char *var, unsigned char *d, size_t len) {
|
||||
printf("size_t %s_len = %ld;\n", var, len);
|
||||
printf("unsigned char %s[%ld] = {\n", var, len);
|
||||
printf("size_t %s_len = %"FMT_SIZE_T";\n", var, (SIZE_T_CAST)len);
|
||||
printf("unsigned char %s[%"FMT_SIZE_T"] = {\n", var, (SIZE_T_CAST)len);
|
||||
size_t i;
|
||||
for(i=0; i<len-1; ++i) {
|
||||
printf("0x%02x, ", (unsigned int)d[i]);
|
||||
|
||||
4
tests/sample.c
Normal file → Executable file
4
tests/sample.c
Normal file → Executable file
@@ -33,7 +33,7 @@ int main() {
|
||||
pcp_encrypt_stream(clear_in, crypt_out, alice, pubhash, 0);
|
||||
|
||||
/* now, print the encrypted result */
|
||||
fprintf(stderr, "Alice encrypted %ld bytes for Bob:\n", strlen(message));
|
||||
fprintf(stderr, "Alice encrypted %"FMT_SIZE_T" bytes for Bob:\n", (SIZE_T_CAST)strlen(message));
|
||||
buffer_dump(ps_buffer(crypt_out));
|
||||
|
||||
/* ---- encryption don, now decrypt ---- */
|
||||
@@ -52,7 +52,7 @@ int main() {
|
||||
fatals_ifany();
|
||||
else {
|
||||
/* and finally print out the decrypted message */
|
||||
fprintf(stderr, "Bob decrypted %ld bytes from Alice:\n", buffer_size(ps_buffer(crypt_out)));
|
||||
fprintf(stderr, "Bob decrypted %"FMT_SIZE_T" bytes from Alice:\n", (SIZE_T_CAST)buffer_size(ps_buffer(crypt_out)));
|
||||
printf("Decrypted message: %s\n", buffer_get_str(ps_buffer(clear_out)));
|
||||
}
|
||||
|
||||
|
||||
2
tests/unittests.cfg
Normal file → Executable file
2
tests/unittests.cfg
Normal file → Executable file
@@ -330,7 +330,7 @@ temporarily disabled
|
||||
</test>
|
||||
<test check-verify-decrypt-from-alicia>
|
||||
cmd = $pcp -V vb -c -d -I testsig -x b
|
||||
expect = /Verified.*Unittests/s
|
||||
expect = /Unittests.*Verified/s
|
||||
</test>
|
||||
|
||||
#
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
#
|
||||
use lib qw(lib);
|
||||
|
||||
BEGIN {
|
||||
eval {
|
||||
use IPC::Run qw( run timeout);
|
||||
};
|
||||
};
|
||||
|
||||
use Test::More;
|
||||
use IPC::Open3;
|
||||
use IO::Select;
|
||||
@@ -29,7 +35,7 @@ use Config::General qw(ParseConfig);
|
||||
use Tie::IxHash;
|
||||
use Data::Dumper;
|
||||
|
||||
sub run;
|
||||
sub run3;
|
||||
sub execute;
|
||||
sub final;
|
||||
|
||||
@@ -119,7 +125,7 @@ sub runtest {
|
||||
|
||||
print STDERR "\n$cfg->{cmd}\n ";
|
||||
|
||||
my $ret = run($cfg->{cmd},
|
||||
my $ret = run3($cfg->{cmd},
|
||||
$cfg->{input},
|
||||
\$out, \$error, 10, 0, undef);
|
||||
|
||||
@@ -203,11 +209,26 @@ sub final {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub run3 {
|
||||
# open3 wrapper. catch stderr, stdout, errno; add timeout and kill
|
||||
my($cmd, $input, $output, $error, $timeout, $debug, $monitorfile) = @_;
|
||||
|
||||
if ($^O =~ /win/i) {
|
||||
my ($o, $e, @c);
|
||||
if ($cmd =~ /\|/) {
|
||||
@c = ("sh", "-c", $cmd);
|
||||
}
|
||||
else {
|
||||
@c = split /\s\s*/, $cmd;
|
||||
}
|
||||
my $ret = run \@c, \$input, \$o, \$e, timeout( $timeout );
|
||||
$$output = $o;
|
||||
$$error = $e;
|
||||
return ret;
|
||||
}
|
||||
|
||||
my ($stdin, $stderr, $stdout) = ('', '', '');
|
||||
|
||||
my $child = 0;
|
||||
my $cmdline = join " ", @{$cmd};
|
||||
$timeout = $timeout ? $timeout : 10;
|
||||
@@ -320,6 +341,20 @@ sub run {
|
||||
}
|
||||
}
|
||||
|
||||
sub runipc {
|
||||
my($cmd, $input, $output, $error, $timeout, $debug, $monitorfile) = @_;
|
||||
|
||||
print STDERR Dumper(\@_);
|
||||
|
||||
if (run $cmd, $input, $output, $error, timeout( $timeout )) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub reaper {
|
||||
my $pid;
|
||||
while (1) {
|
||||
|
||||
Reference in New Issue
Block a user