Skip to content

Commit

Permalink
Set optimization flag to -O3 and error on warninings (#42)
Browse files Browse the repository at this point in the history
* add opt flags and error flags

Signed-off-by: Matthias J. Kannwischer <[email protected]>

* failed ci if there is any error for running the tests

Signed-off-by: Thing-han, Lim <[email protected]>

* failed tests script if make failed

Signed-off-by: Thing-han, Lim <[email protected]>

* fix array boundary check in nistkat test

Signed-off-by: Thing-han, Lim <[email protected]>

* remove pedantic flag

Signed-off-by: Thing-han, Lim <[email protected]>

---------

Signed-off-by: Matthias J. Kannwischer <[email protected]>
Signed-off-by: Thing-han, Lim <[email protected]>
Co-authored-by: Thing-han, Lim <[email protected]>
  • Loading branch information
mkannwischer and potsrevennil authored May 24, 2024
1 parent 77e957b commit e4bc215
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ jobs:
shell: nix develop .#ci -c bash -e {0}
run: |
make_platform() {
echo "::group::make platform $1"
make PLATFORM="$1"
echo "::endgroup::"
echo "::group::make platform $1"
make PLATFORM="$1"
code1=$?
echo "::endgroup::"
echo "::group::make platform $1 nistkat"
make PLATFORM="$1" RNG=NISTKAT nistkat
echo "::endgroup::"
echo "::group::make platform $1 nistkat"
make PLATFORM="$1" RNG=NISTKAT nistkat
code2=$?
echo "::endgroup::"
return $(( code1 || code2 ))
}
export -f make_platform
tests --list-platforms | grep -v "mps2" | xargs -I {} bash -c 'make_platform "$@"' _ {}
tests --list-platforms | grep -v "mps2" | xargs -I {} bash -c 'make_platform "$@" || exit 1' _ {}
- name: Functional test
id: func_test
Expand Down
3 changes: 2 additions & 1 deletion mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ LIBDEPS += obj/libhal.a
include mk/$(PLATFORM).mk

CFLAGS += \
-O3 \
-std=gnu99 \
--sysroot=$(SYSROOT) \
-Wall -Wextra -Wshadow \
-Wall -Wextra -Wshadow -Werror \
-MMD \
-fno-common \
-Imlkem -Ifips202 -Ihal \
Expand Down
10 changes: 6 additions & 4 deletions scripts/ci/tests-qemu
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,31 @@ _run()
local platform="$2"
echo "::group:: $test_type test for $platform"
tests "$test_type" "$platform" -v
code=$?
echo "::endgroup::"
return $code
}

export -f _run

func()
{
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run func "$@"' _ {}
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run func "$@" || exit 1' _ {}
}

speed()
{
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run speed "$@"' _ {}
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run speed "$@" || exit 1' _ {}
}

stack()
{
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run stack "$@"' _ {}
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run stack "$@" || exit 1' _ {}
}

nistkat()
{
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run nistkat "$@"' _ {}
tests --list-platforms | grep "mps2" | xargs -I {} bash -c '_run nistkat "$@" || exit 1' _ {}
}

declare -f -F "$1" && true >/dev/null
Expand Down
4 changes: 4 additions & 0 deletions scripts/tests
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def base_test(
)
logging.info(format(subprocess.list2cmdline(p.args)))

if p.returncode != 0:
logging.error("make failed")
sys.exit(1)

def check(file, expect, actual):
if actual != expect:
logging.error(
Expand Down
2 changes: 1 addition & 1 deletion test/nistkat.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ size_t format_bstr(char *buf, const char *S, const uint8_t *A, size_t L) {

void inc_hash_bstr(shake256incctx *state, const char *S, const uint8_t *A, size_t L) {
size_t len;
char buf[strlen(S) + 2 * L + 1];
char buf[strlen(S) + 2 * L + 2];

len = format_bstr(buf, S, A, L);
len += snprintf(buf + strlen(S) + 2 * L, 2, "\n");
Expand Down

0 comments on commit e4bc215

Please sign in to comment.