From 91c58506e54519e11f0ec0acb1c09825522af38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 1 Apr 2020 23:16:02 +0200 Subject: [PATCH] Enable R2R in C for all CI except Windows (#16354) ##test --- .builds/freebsd.yml | 19 +++++++++++++++---- .builds/openbsd.yml | 22 ++++++++++++++++++---- .github/workflows/ccpp.yml | 13 +++++++++---- libr/util/file.c | 1 + libr/util/sys.c | 23 ----------------------- test/Makefile | 9 ++++++++- test/new/db/cmd/cmd_i | 1 + test/new/db/formats/mangling/swift | 1 + test/new/db/tools/rabin2 | 1 + test/new/db/tools/rasm2 | 2 ++ travis-script | 1 - 11 files changed, 56 insertions(+), 37 deletions(-) diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index aaa74b4b5c..73d6d437e7 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -5,12 +5,14 @@ packages: - devel/gmake - devel/llvm - ftp/wget + - lang/python environment: CXX: clang++ CC: clang HOST_CC: clang sources: - https://github.com/radareorg/radare2 + - https://github.com/radareorg/radare2-testbins tasks: - build: | cd radare2 @@ -18,9 +20,18 @@ tasks: gmake - install: | cd radare2 - export PATH=${HOME}/install/bin:${PATH} - export LD_LIBRARY_PATH=${HOME}/install/lib:${HOME}/install/lib64:${LD_LIBRARY_PATH} + export PATH=${HOME}/bin:${PATH} + export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH} export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH} gmake install - # Running the new V suite - r2r -L + - test: | + cd radare2 + export PATH=${HOME}/bin:${PATH} + export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH} + export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH} + # Workaround until the feature request is solved + # https://todo.sr.ht/~sircmpwn/builds.sr.ht/274 + ln -s ${HOME}/radare2-testbins test/bins + # Running the test suite + cd test && gmake -k all + diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml index 8b128a837f..2cd592bd0c 100644 --- a/.builds/openbsd.yml +++ b/.builds/openbsd.yml @@ -4,11 +4,13 @@ packages: - devel/pkgconf - devel/gmake - devel/llvm + - lang/python environment: CXX: clang++ CC: clang sources: - https://github.com/radareorg/radare2 + - https://github.com/radareorg/radare2-testbins tasks: - build: | cd radare2 @@ -16,9 +18,21 @@ tasks: gmake - install: | cd radare2 - export PATH=${HOME}/install/bin:${PATH} - export LD_LIBRARY_PATH=${HOME}/install/lib:${HOME}/install/lib64:${LD_LIBRARY_PATH} + export PATH=${HOME}/bin:${PATH} + export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH} export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH} gmake install - # Running the new V suite - r2r -L + - test: | + cd radare2 + export PATH=${HOME}/bin:${PATH} + export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH} + export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH} + # OpenBSD does not have a "python" command by default + # but a test needs it. + ln -s /usr/local/bin/python3 ${HOME}/bin/python + # Workaround until the feature request is solved + # https://todo.sr.ht/~sircmpwn/builds.sr.ht/274 + ln -s ${HOME}/radare2-testbins test/bins + # Running the test suite + cd test && gmake -k all + diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 292e6d4174..95d1e08ea4 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -21,6 +21,11 @@ jobs: - name: Install pkg-config with Homebrew if: matrix.os == 'macos-latest' run: brew install pkg-config + - name: Checkout our Testsuite Binaries + uses: actions/checkout@v2 + with: + repository: radareorg/radare2-testbins + path: test/bins - name: Configure with ACR run: ./configure --prefix=${HOME} - name: Build @@ -28,10 +33,10 @@ jobs: - name: Install and run tests run: | # Install the radare2 - export PATH=${HOME}/install/bin:${PATH} - export LD_LIBRARY_PATH=${HOME}/install/lib:${HOME}/install/lib64:${LD_LIBRARY_PATH} + export PATH=${HOME}/bin:${PATH} + export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH} export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH} make install - # Running the new C suite - # r2r -L + # Running the test suite + cd test && make diff --git a/libr/util/file.c b/libr/util/file.c index e460a4fc03..8427097f5c 100644 --- a/libr/util/file.c +++ b/libr/util/file.c @@ -816,6 +816,7 @@ err_r_file_mmap_write: return -1; } memcpy (mmap_buf+rest, buf, len); + msync (mmap_buf+rest, len, MS_INVALIDATE); munmap (mmap_buf, mmlen*2); close (fd); return len; diff --git a/libr/util/sys.c b/libr/util/sys.c index 25e84ca8da..76d8583a95 100644 --- a/libr/util/sys.c +++ b/libr/util/sys.c @@ -785,30 +785,7 @@ R_API int r_sys_cmd(const char *str) { if (r_sandbox_enable (0)) { return false; } -#if __FreeBSD__ - /* freebsd system() is broken */ - int st, pid, fds[2]; - if (pipe (fds)) { - return -1; - } - pid = vfork (); - if (pid == -1) { - return -1; - } - if (!pid) { - dup2 (1, fds[1]); - // char *argv[] = { "/bin/sh", "-c", str, NULL}; - // execv (argv[0], argv); - r_sandbox_system (str, 0); - _exit (127); /* error */ - } else { - dup2 (1, fds[0]); - waitpid (pid, &st, 0); - } - return WEXITSTATUS (st); -#else return r_sandbox_system (str, 1); -#endif } R_API char *r_sys_cmd_str(const char *cmd, const char *input, int *len) { diff --git a/test/Makefile b/test/Makefile index c583839e63..038a859c32 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,7 @@ R2R=$(shell cd new ; npm bin)/r2r RUNTEST=cd new && npm install ; $(R2R) -all: js-tests unit_tests +all: r2r-tests unit_tests bins: git clone --depth 1 https://github.com/radareorg/radare2-testbins bins @@ -9,7 +9,14 @@ bins: fuzz/targets: git clone --depth 1 https://github.com/radareorg/radare2-fuzztargets fuzz/targets +R2R_JS=$(shell cd new ; npm bin)/r2r + js-tests: bins + cd new && npm install ; $(R2R_JS) + +RUNTEST=cd new && r2r -L + +r2r-tests: bins ${RUNTEST} keystone: bins diff --git a/test/new/db/cmd/cmd_i b/test/new/db/cmd/cmd_i index 0978fd2e48..08e7889fef 100644 --- a/test/new/db/cmd/cmd_i +++ b/test/new/db/cmd/cmd_i @@ -1445,6 +1445,7 @@ RUN NAME=iD FILE=../bins/elf/libmagic.so +BROKEN=1 EXPECT=< String EOF diff --git a/test/new/db/formats/mangling/swift b/test/new/db/formats/mangling/swift index b126a486ad..b2fe84acbf 100644 --- a/test/new/db/formats/mangling/swift +++ b/test/new/db/formats/mangling/swift @@ -8,6 +8,7 @@ RUN NAME=elf swift demangle (requires swift-demangle program) FILE=../bins/elf/analysis/hello-swift +BROKEN=1 EXPECT=< String EOF diff --git a/test/new/db/tools/rabin2 b/test/new/db/tools/rabin2 index 4515582b80..234129ed1a 100644 --- a/test/new/db/tools/rabin2 +++ b/test/new/db/tools/rabin2 @@ -834,6 +834,7 @@ EOF RUN NAME=rabin2 -D swift +BROKEN=1 FILE=../bins/elf/libc.so.0 CMDS=!rabin2 -D swift _TFSSCfT21_builtinStringLiteralBp8byteSizeBw7isASCIIBi1__SS EXPECT=<