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

Enabling out-of-source build-and-test #1091

Merged
merged 5 commits into from
Sep 18, 2021
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ tags
*~
.tags*

# CMake
# CMake & testing
/build*
/tmp*

# MSVC
.vs
Expand Down
4 changes: 2 additions & 2 deletions tests/test_kem_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ int main(int argc, char **argv) {
// Use system RNG in this program
OQS_randombytes_switch_algorithm(OQS_RAND_alg_system);

OQS_STATUS rc;
oqs_fstore_init();

rc = kem_test_correctness(alg_name, (unsigned int)atoi(argv[2]));
OQS_STATUS rc = kem_test_correctness(alg_name, (unsigned int)atoi(argv[2]));

if (rc != OQS_SUCCESS) {
return EXIT_FAILURE;
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sig_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ int main(int argc, char **argv) {
// Use system RNG in this program
OQS_randombytes_switch_algorithm(OQS_RAND_alg_system);

oqs_fstore_init();

OQS_STATUS rc = sig_test_correctness(alg_name, (unsigned int)atoi(argv[2]));

if (rc != OQS_SUCCESS) {
Expand Down
3 changes: 2 additions & 1 deletion tests/test_spdx.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# SPDX-License-Identifier: MIT

find . \( -name '*.[chsS]' -or -name '*.cmake' -or -name '*.py' -or -name '*.sh' -or -name 'CMakeLists.txt' \) -and -type f | grep -v '/external/' | grep -v 'kem/.*/.*/.*' | grep -v 'sig/.*/.*/.*' | grep -v 'build' | grep -v 'xkcp_low' | grep -v 'patches' | xargs grep -L 'SPDX-License-Identifier' | sort
BD=${OQS_BUILD_DIR:-build}
find . \( -name '*.[chsS]' -or -name '*.cmake' -or -name '*.py' -or -name '*.sh' -or -name 'CMakeLists.txt' \) -and -type f | grep -v '/external/' | grep -v 'kem/.*/.*/.*' | grep -v 'sig/.*/.*/.*' | grep -v 'xkcp_low' | grep -v 'patches' | grep -v `basename $BD` | xargs grep -L 'SPDX-License-Identifier' | sort
25 changes: 20 additions & 5 deletions tests/tmp_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/stat.h>

#define STORE_PREFIX "build/mem-benchmark/oqs-temp-file-"
#define OQS_STORE_DIR "tmp"
#define OQS_STORE_PREFIX "/oqs-temp-file-"
#define MAXPATHLEN 128

#if (defined(_WIN32) || defined(__WIN32__))
#define mkdir(A, B) mkdir(A)
#endif

static OQS_STATUS oqs_fstore_init(void) {
return mkdir(OQS_STORE_DIR, 0755);
}

static OQS_STATUS oqs_fstore(const char *fname, const char *mname, uint8_t *data, size_t len) {
char fpath[MAXPATHLEN];
strcpy(fpath, STORE_PREFIX);
strcpy(fpath, OQS_STORE_DIR);
strcat(fpath, OQS_STORE_PREFIX);
strcat(fpath, mname);
FILE *fp = fopen(strcat(fpath, fname), "wb");
strcat(fpath, fname);
FILE *fp = fopen(fpath, "wb");
if (!fp) {
fprintf(stderr, "Couldn't open %s for writing.\n", fpath);
return OQS_ERROR;
Expand All @@ -25,9 +38,11 @@ static OQS_STATUS oqs_fload(const char *fname, const char *mname, uint8_t *data,
size_t len_read = 0, r = 0;
uint8_t *dr = NULL;
char fpath[MAXPATHLEN];
strcpy(fpath, STORE_PREFIX);
strcpy(fpath, OQS_STORE_DIR);
strcat(fpath, OQS_STORE_PREFIX);
strcat(fpath, mname);
FILE *fp = fopen(strcat(fpath, fname), "rb");
strcat(fpath, fname);
FILE *fp = fopen(fpath, "rb");
if (!fp) {
fprintf(stderr, "Couldn't open %s for reading.\n", fpath);
return OQS_ERROR;
Expand Down