Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libcperciva import and trivial fixes #376

Merged
merged 6 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib-platform/crypto/crypto_scrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#include "crypto_scrypt.h"

static void (*smix_func)(uint8_t *, size_t, uint64_t, void *, void *) = NULL;
static void (* smix_func)(uint8_t *, size_t, uint64_t, void *, void *) = NULL;

/**
* crypto_scrypt_internal(passwd, passwdlen, salt, saltlen, N, r, p, buf,
Expand All @@ -56,7 +56,7 @@ static int
crypto_scrypt_internal(const uint8_t * passwd, size_t passwdlen,
const uint8_t * salt, size_t saltlen, uint64_t N, uint32_t _r, uint32_t _p,
uint8_t * buf, size_t buflen,
void (*smix)(uint8_t *, size_t, uint64_t, void *, void *))
void (* smix)(uint8_t *, size_t, uint64_t, void *, void *))
{
void * B0, * V0, * XY0;
uint8_t * B;
Expand Down Expand Up @@ -192,7 +192,7 @@ static struct scrypt_test {
};

static int
testsmix(void (*smix)(uint8_t *, size_t, uint64_t, void *, void *))
testsmix(void (* smix)(uint8_t *, size_t, uint64_t, void *, void *))
{
uint8_t hbuf[TESTLEN];

Expand Down
1 change: 1 addition & 0 deletions lib/scryptenc/scryptenc_cpuperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ getclockdiff(struct timeval * st, double * diffd)
return (1);
*diffd = timeval_diff((*st), en);

/* Success! */
return (0);
}

Expand Down
4 changes: 4 additions & 0 deletions libcperciva/POSIX/posix-abstract-declarator.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ func(int arr[static restrict 1])
{

(void)arr; /* UNUSED */

/* Success! */
return (0);
}

Expand All @@ -17,5 +19,7 @@ main(void)
{

(void)func; /* UNUSED */

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions libcperciva/POSIX/posix-stat-st_mtim.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ main(void)
/* Can we reference st_mtim? */
(void)sb.st_mtim.tv_sec;

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions libcperciva/POSIX/posix-trivial.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ int
main(void)
{

/* Success! */
return (0);
}
2 changes: 1 addition & 1 deletion libcperciva/alg/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int
hwtest(const uint32_t state[static restrict 8],
const uint8_t block[static restrict 64],
uint32_t W[static restrict 64], uint32_t S[static restrict 8],
void(* func)(uint32_t state[static restrict 8],
void (* func)(uint32_t state[static restrict 8],
const uint8_t block[static restrict 64], uint32_t W[static restrict 64],
uint32_t S[static restrict 8]))
{
Expand Down
1 change: 1 addition & 0 deletions libcperciva/cpusupport/Build/cpusupport-ARM-AES.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ main(void)

lanes = vdupq_laneq_u32(lanes, 0);

/* Success! */
return (0);
}
1 change: 1 addition & 0 deletions libcperciva/cpusupport/Build/cpusupport-ARM-SHA256.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ main(void)
output = vsha256su0q_u32(w0, w4);
(void)output; /* UNUSED */

/* Success! */
return (0);
}
2 changes: 1 addition & 1 deletion libcperciva/crypto/crypto_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static struct aes_test {

/* Test a function against test vectors. */
static int
functest(int(* func)(const uint8_t *, size_t, const uint8_t[16], uint8_t[16]))
functest(int (* func)(const uint8_t *, size_t, const uint8_t[16], uint8_t[16]))
{
struct aes_test * knowngood;
uint8_t ctext[16];
Expand Down
1 change: 1 addition & 0 deletions libcperciva/crypto/crypto_aesctr_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ crypto_aesctr_stream_pre_wholeblock(struct crypto_aesctr * stream,
buflen_p, 16 - bytemod, bytemod);
}

/* Success! */
return (0);
}

Expand Down
4 changes: 2 additions & 2 deletions libcperciva/util/monoclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ monoclock_get_cputime(struct timeval * tv)

/**
* monoclock_getres(resd):
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC is
* available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC
* is available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* CLOCK_REALTIME (if available) or gettimeofday(2). For this value to be
* meaningful, we assume that clock_getres(x) succeeds iff clock_gettime(x)
* succeeds.
Expand Down
4 changes: 2 additions & 2 deletions libcperciva/util/monoclock.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ int monoclock_get_cputime(struct timeval *);

/**
* monoclock_getres(resd):
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC is
* available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* Store an upper limit on timer granularity in ${resd}. If CLOCK_MONOTONIC
* is available, use that clock; if CLOCK_MONOTONIC is unavailable, use
* CLOCK_REALTIME (if available) or gettimeofday(2). For this value to be
* meaningful, we assume that clock_getres(x) succeeds iff clock_gettime(x)
* succeeds.
Expand Down
31 changes: 18 additions & 13 deletions tests/shared_test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#
### Design
#
# The main function is scenario_runner(scenario_filename), which
# The main function is _scenario_runner(scenario_filename), which
# takes a scenario file as the argument, and runs a
# scenario_cmd()
# function which was defined in that file.
#
# Functions which are available to other scripts as a "public API" are:
# - find_system(cmd, args):
# Look for ${cmd} in the ${PATH}, and ensure that it supports ${args}.
# - has_pid(cmd):
# Look for a ${cmd} in $(ps).
# - wait_while(func):
Expand All @@ -29,6 +31,8 @@
# - run_scenarios():
# Run scenarios in the test directory.
#
# We adopt the convention of "private" function names beginning with an _.
#
### Variables
#
# Wherever possible, this suite uses local variables and
Expand Down Expand Up @@ -73,9 +77,9 @@ bindir=$(CDPATH='' cd -- "$(dirname -- "${1-.}")" && pwd -P)
NO_EXITFILE=/dev/null


## prepare_directory():
## _prepare_directory():
# Delete the previous test output directory, and create a new one.
prepare_directory() {
_prepare_directory() {
if [ -d "${out}" ]; then
rm -rf "${out}"
fi
Expand All @@ -86,7 +90,7 @@ prepare_directory() {
}

## find_system (cmd, args):
# Look for ${cmd} in the $PATH, and ensure that it supports ${args}.
# Look for ${cmd} in the ${PATH}, and ensure that it supports ${args}.
find_system() {
cmd=$1
cmd_with_args="$1 ${2:-}"
Expand Down Expand Up @@ -207,14 +211,14 @@ expected_exitcode() {
fi
}

## notify_success_or_fail (log_basename, val_log_basename):
## _notify_success_or_fail (log_basename, val_log_basename):
# Examine all "exit code" files beginning with ${log_basename} and
# print "SUCCESS!", "FAILED!", "SKIP!", or "PARTIAL SUCCESS / SKIP!"
# as appropriate. Check any valgrind log files associated with the
# test and print "FAILED!" if appropriate, along with the valgrind
# logfile. If the test failed and ${VERBOSE} is non-zero, print
# the description to stderr.
notify_success_or_fail() {
_notify_success_or_fail() {
log_basename=$1
val_log_basename=$2

Expand Down Expand Up @@ -278,9 +282,9 @@ notify_success_or_fail() {
fi
}

## scenario_runner (scenario_filename):
## _scenario_runner (scenario_filename):
# Run a test scenario from ${scenario_filename}.
scenario_runner() {
_scenario_runner() {
scenario_filename=$1
basename=$(basename "${scenario_filename}" .sh)
printf " %s... " "${basename}" 1>&2
Expand All @@ -307,13 +311,14 @@ scenario_runner() {

# Print PASS or FAIL, and return result.
s_retval=0
notify_success_or_fail "${s_basename}" "${s_val_basename}"
_notify_success_or_fail "${s_basename}" "${s_val_basename}"

return "${s_retval}"
}

## run_scenarios (scenario_filenames):
# Run all scenarios matching ${scenario_filenames}.
## run_scenarios ():
# Run all scenarios in the test directory. If the environment variable ${N}
# is specified, only run the scenario corresponding to that number.
run_scenarios() {
# Get the test number(s) to run.
if [ "${N:-0}" -gt "0" ]; then
Expand All @@ -323,7 +328,7 @@ run_scenarios() {
fi

# Clean up any previous directory, and create a new one.
prepare_directory
_prepare_directory

# Clean up any previous valgrind directory, and prepare for new
# valgrind tests (if applicable).
Expand All @@ -334,7 +339,7 @@ run_scenarios() {
for scenario in ${test_scenarios}; do
# We can't call this function with $( ... ) because we
# want to allow it to echo values to stdout.
scenario_runner "${scenario}"
_scenario_runner "${scenario}"
retval=$?
if [ "${retval}" -gt 0 ]; then
exit "${retval}"
Expand Down
Loading