Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/tests/usr.bin/cc Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/60d5f7b6fcd7
branches:  netbsd-9
changeset: 962886:60d5f7b6fcd7
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Aug 29 16:45:25 2019 +0000

description:
Pull up following revision(s) (requested by kamil in ticket #120):

        tests/usr.bin/cc/t_msan_poison.sh: revision 1.1
        tests/usr.bin/cc/t_msan_allocated_memory.sh: revision 1.2
        tests/usr.bin/cc/t_msan_poison.sh: revision 1.2
        tests/usr.bin/c++/t_fuzzer_oom.sh: revision 1.1
        tests/usr.bin/cc/t_tsan_signal_errno.sh: revision 1.1
        tests/usr.bin/c++/t_fuzzer_simple.sh: revision 1.1
        tests/usr.bin/c++/t_fuzzer_oom.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_signal_errno.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_heap_use_after_free.sh: revision 1.1
        tests/usr.bin/c++/t_fuzzer_simple.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_heap_use_after_free.sh: revision 1.2
        tests/usr.bin/c++/t_tsan_thread_leak.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_thread_leak.sh: revision 1.2
        tests/usr.bin/cc/t_fuzzer_oom.sh: revision 1.1
        distrib/sets/lists/tests/mi: revision 1.819
        tests/usr.bin/cc/t_fuzzer_oom.sh: revision 1.2
        tests/usr.bin/cc/t_fuzzer_timeout.sh: revision 1.1
        tests/usr.bin/cc/t_msan_unpoison.sh: revision 1.1
        tests/usr.bin/cc/t_fuzzer_timeout.sh: revision 1.2
        tests/usr.bin/cc/t_msan_unpoison.sh: revision 1.2
        tests/usr.bin/c++/t_msan_heap.sh: revision 1.1
        tests/usr.bin/cc/t_tsan_locked_mutex_destroy.sh: revision 1.1
        tests/usr.bin/c++/t_msan_heap.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_locked_mutex_destroy.sh: revision 1.2
        tests/usr.bin/cc/Makefile: revision 1.8
        tests/usr.bin/c++/t_msan_free.sh: revision 1.1
        tests/usr.bin/c++/t_msan_unpoison.sh: revision 1.1
        tests/usr.bin/c++/t_msan_free.sh: revision 1.2
        tests/usr.bin/c++/t_msan_unpoison.sh: revision 1.2
        tests/usr.bin/c++/t_tsan_heap_use_after_free.sh: revision 1.1
        tests/usr.bin/cc/t_tsan_lock_order_inversion.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_heap_use_after_free.sh: revision 1.2
        tests/usr.bin/c++/t_msan_poison.sh: revision 1.1
        tests/usr.bin/c++/t_msan_partial_poison.sh: revision 1.1
        tests/usr.bin/cc/t_tsan_lock_order_inversion.sh: revision 1.2
        tests/usr.bin/c++/t_msan_poison.sh: revision 1.2
        tests/usr.bin/c++/t_msan_partial_poison.sh: revision 1.2
        tests/usr.bin/c++/t_msan_realloc.sh: revision 1.1
        tests/usr.bin/cc/t_msan_shadow.sh: revision 1.1
        tests/usr.bin/cc/t_msan_partial_poison.sh: revision 1.1
        tests/usr.bin/c++/t_msan_realloc.sh: revision 1.2
        tests/usr.bin/c++/t_msan_allocated_memory.sh: revision 1.1
        tests/usr.bin/cc/t_msan_shadow.sh: revision 1.2
        tests/usr.bin/cc/t_msan_partial_poison.sh: revision 1.2
        tests/usr.bin/c++/t_msan_allocated_memory.sh: revision 1.2
        tests/usr.bin/cc/t_msan_free.sh: revision 1.1
        tests/usr.bin/cc/t_msan_free.sh: revision 1.2
        tests/usr.bin/c++/t_tsan_locked_mutex_destroy.sh: revision 1.1
        tests/usr.bin/c++/t_fuzzer_timeout.sh: revision 1.1
        tests/usr.bin/cc/t_msan_heap.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_locked_mutex_destroy.sh: revision 1.2
        tests/usr.bin/c++/t_fuzzer_timeout.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_thread_leak.sh: revision 1.1
        tests/usr.bin/cc/t_msan_heap.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_thread_leak.sh: revision 1.2
        tests/usr.bin/cc/t_tsan_data_race.sh: revision 1.1
        tests/usr.bin/cc/t_tsan_data_race.sh: revision 1.2
        tests/usr.bin/c++/t_tsan_lock_order_inversion.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_signal_errno.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_lock_order_inversion.sh: revision 1.2
        tests/usr.bin/c++/Makefile: revision 1.12
        tests/usr.bin/c++/t_tsan_signal_errno.sh: revision 1.2
        tests/usr.bin/cc/t_msan_check_mem.sh: revision 1.1
        tests/usr.bin/cc/t_msan_check_mem.sh: revision 1.2
        tests/usr.bin/cc/t_msan_realloc.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_vptr_race.sh: revision 1.1
        tests/usr.bin/cc/t_msan_realloc.sh: revision 1.2
        tests/usr.bin/c++/t_tsan_vptr_race.sh: revision 1.2
        tests/usr.bin/c++/t_msan_shadow.sh: revision 1.1
        tests/usr.bin/c++/t_msan_shadow.sh: revision 1.2
        tests/usr.bin/c++/t_msan_stack.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_data_race.sh: revision 1.1
        tests/usr.bin/c++/t_msan_stack.sh: revision 1.2
        tests/usr.bin/cc/t_fuzzer_simple.sh: revision 1.1
        tests/usr.bin/c++/t_tsan_data_race.sh: revision 1.2
        tests/usr.bin/cc/t_fuzzer_simple.sh: revision 1.2
        tests/usr.bin/c++/t_msan_check_mem.sh: revision 1.1
        tests/usr.bin/cc/t_msan_stack.sh: revision 1.1
        tests/usr.bin/c++/t_msan_check_mem.sh: revision 1.2
        tests/usr.bin/cc/t_msan_stack.sh: revision 1.2
        tests/usr.bin/cc/t_msan_allocated_memory.sh: revision 1.1

Add ATF c and c++ tests for TSan, MSan, libFuzzer

These tests require Clang/LLVM 7 or newer on NetBSD.

Contributed by Yang Zheng during GSoC 2018.

 -

Define target_not_supported_body() in TSan, MSan and libFuzzer tests

diffstat:

 distrib/sets/lists/tests/mi                      |   41 +++-
 tests/usr.bin/c++/Makefile                       |   25 ++-
 tests/usr.bin/c++/t_fuzzer_oom.sh                |  171 ++++++++++++++++
 tests/usr.bin/c++/t_fuzzer_simple.sh             |  187 ++++++++++++++++++
 tests/usr.bin/c++/t_fuzzer_timeout.sh            |  167 ++++++++++++++++
 tests/usr.bin/c++/t_msan_allocated_memory.sh     |  168 ++++++++++++++++
 tests/usr.bin/c++/t_msan_check_mem.sh            |  172 ++++++++++++++++
 tests/usr.bin/c++/t_msan_free.sh                 |  164 ++++++++++++++++
 tests/usr.bin/c++/t_msan_heap.sh                 |  144 ++++++++++++++
 tests/usr.bin/c++/t_msan_partial_poison.sh       |  176 +++++++++++++++++
 tests/usr.bin/c++/t_msan_poison.sh               |  172 ++++++++++++++++
 tests/usr.bin/c++/t_msan_realloc.sh              |  168 ++++++++++++++++
 tests/usr.bin/c++/t_msan_shadow.sh               |  188 ++++++++++++++++++
 tests/usr.bin/c++/t_msan_stack.sh                |  164 ++++++++++++++++
 tests/usr.bin/c++/t_msan_unpoison.sh             |  188 ++++++++++++++++++
 tests/usr.bin/c++/t_tsan_data_race.sh            |  185 ++++++++++++++++++
 tests/usr.bin/c++/t_tsan_heap_use_after_free.sh  |  221 +++++++++++++++++++++
 tests/usr.bin/c++/t_tsan_lock_order_inversion.sh |  205 ++++++++++++++++++++
 tests/usr.bin/c++/t_tsan_locked_mutex_destroy.sh |  221 +++++++++++++++++++++
 tests/usr.bin/c++/t_tsan_signal_errno.sh         |  209 ++++++++++++++++++++
 tests/usr.bin/c++/t_tsan_thread_leak.sh          |  209 ++++++++++++++++++++
 tests/usr.bin/c++/t_tsan_vptr_race.sh            |  233 +++++++++++++++++++++++
 tests/usr.bin/cc/Makefile                        |   24 ++-
 tests/usr.bin/cc/t_fuzzer_oom.sh                 |  171 ++++++++++++++++
 tests/usr.bin/cc/t_fuzzer_simple.sh              |  187 ++++++++++++++++++
 tests/usr.bin/cc/t_fuzzer_timeout.sh             |  167 ++++++++++++++++
 tests/usr.bin/cc/t_msan_allocated_memory.sh      |  169 ++++++++++++++++
 tests/usr.bin/cc/t_msan_check_mem.sh             |  173 +++++++++++++++++
 tests/usr.bin/cc/t_msan_free.sh                  |  164 ++++++++++++++++
 tests/usr.bin/cc/t_msan_heap.sh                  |  144 ++++++++++++++
 tests/usr.bin/cc/t_msan_partial_poison.sh        |  176 +++++++++++++++++
 tests/usr.bin/cc/t_msan_poison.sh                |  172 ++++++++++++++++
 tests/usr.bin/cc/t_msan_realloc.sh               |  168 ++++++++++++++++
 tests/usr.bin/cc/t_msan_shadow.sh                |  188 ++++++++++++++++++
 tests/usr.bin/cc/t_msan_stack.sh                 |  164 ++++++++++++++++
 tests/usr.bin/cc/t_msan_unpoison.sh              |  188 ++++++++++++++++++
 tests/usr.bin/cc/t_tsan_data_race.sh             |  185 ++++++++++++++++++
 tests/usr.bin/cc/t_tsan_heap_use_after_free.sh   |  221 +++++++++++++++++++++
 tests/usr.bin/cc/t_tsan_lock_order_inversion.sh  |  205 ++++++++++++++++++++
 tests/usr.bin/cc/t_tsan_locked_mutex_destroy.sh  |  221 +++++++++++++++++++++
 tests/usr.bin/cc/t_tsan_signal_errno.sh          |  209 ++++++++++++++++++++
 tests/usr.bin/cc/t_tsan_thread_leak.sh           |  209 ++++++++++++++++++++
 42 files changed, 7280 insertions(+), 3 deletions(-)

diffs (truncated from 7488 to 300 lines):

diff -r 9bafacb17eba -r 60d5f7b6fcd7 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Aug 29 06:46:44 2019 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Aug 29 16:45:25 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.818 2019/07/28 13:49:23 christos Exp $
+# $NetBSD: mi,v 1.818.2.1 2019/08/29 16:45:26 martin Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3840,6 +3840,26 @@
 ./usr/tests/usr.bin/c++/t_ubsan_int_neg_overflow       tests-usr.bin-tests     compattestfile,atf,cxx
 ./usr/tests/usr.bin/c++/t_ubsan_int_sub_overflow       tests-usr.bin-tests     compattestfile,atf,cxx
 ./usr/tests/usr.bin/c++/t_ubsan_vla_out_of_bounds      tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_allocated_memory        tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_check_mem       tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_free            tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_heap            tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_partial_poison  tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_poison          tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_realloc         tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_shadow          tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_stack           tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_msan_unpoison                tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_data_race       tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_heap_use_after_free     tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_lock_order_inversion    tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_locked_mutex_destroy    tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_signal_errno    tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_thread_leak     tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_tsan_vptr_race       tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_fuzzer_oom           tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_fuzzer_simple                tests-usr.bin-tests     compattestfile,atf,cxx
+./usr/tests/usr.bin/c++/t_fuzzer_timeout       tests-usr.bin-tests     compattestfile,atf,cxx
 ./usr/tests/usr.bin/cc                         tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cc/Atffile                 tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cc/Kyuafile                        tests-usr.bin-tests     compattestfile,atf,kyua
@@ -3856,6 +3876,25 @@
 ./usr/tests/usr.bin/cc/t_ubsan_int_neg_overflow                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cc/t_ubsan_int_sub_overflow                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cc/t_ubsan_vla_out_of_bounds       tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_allocated_memory         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_check_mem                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_free             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_heap             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_partial_poison    tests-usr.bin-tests    compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_poison           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_realloc          tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_shadow           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_stack            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_msan_unpoison         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_tsan_data_race                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_tsan_heap_use_after_free      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_tsan_lock_order_inversion     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_tsan_locked_mutex_destroy     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_tsan_signal_errno     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_tsan_thread_leak      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_fuzzer_oom            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_fuzzer_simple         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/cc/t_fuzzer_timeout                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cmp                                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cmp/Atffile                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/cmp/Kyuafile               tests-usr.bin-tests     compattestfile,atf,kyua
diff -r 9bafacb17eba -r 60d5f7b6fcd7 tests/usr.bin/c++/Makefile
--- a/tests/usr.bin/c++/Makefile        Thu Aug 29 06:46:44 2019 +0000
+++ b/tests/usr.bin/c++/Makefile        Thu Aug 29 16:45:25 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2019/01/29 20:07:03 mgorny Exp $
+# $NetBSD: Makefile,v 1.11.2.1 2019/08/29 16:45:26 martin Exp $
 
 .include <bsd.own.mk>
 
@@ -29,6 +29,29 @@
 TESTS_SH+=     t_pthread_once
 TESTS_SH+=     t_static_destructor
 
+TESTS_SH+=     t_fuzzer_oom
+TESTS_SH+=     t_fuzzer_simple
+TESTS_SH+=     t_fuzzer_timeout
+
+TESTS_SH+=     t_msan_allocated_memory
+TESTS_SH+=     t_msan_check_mem
+TESTS_SH+=     t_msan_free
+TESTS_SH+=     t_msan_heap
+TESTS_SH+=     t_msan_partial_poison
+TESTS_SH+=     t_msan_poison
+TESTS_SH+=     t_msan_realloc
+TESTS_SH+=     t_msan_shadow
+TESTS_SH+=     t_msan_stack
+TESTS_SH+=     t_msan_unpoison
+
+TESTS_SH+=     t_tsan_data_race
+TESTS_SH+=     t_tsan_heap_use_after_free
+TESTS_SH+=     t_tsan_lock_order_inversion
+TESTS_SH+=     t_tsan_locked_mutex_destroy
+TESTS_SH+=     t_tsan_signal_errno
+TESTS_SH+=     t_tsan_thread_leak
+TESTS_SH+=     t_tsan_vptr_race
+
 .for test in ${ASAN_TESTS}
 TESTS_SH_SRC_${test}=  asan_common.subr ${test}.sh
 .endfor
diff -r 9bafacb17eba -r 60d5f7b6fcd7 tests/usr.bin/c++/t_fuzzer_oom.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/c++/t_fuzzer_oom.sh Thu Aug 29 16:45:25 2019 +0000
@@ -0,0 +1,171 @@
+# Copyright (c) 2018 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Yang Zheng.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+test_target()
+{
+       SUPPORT='n'
+       if uname -m | grep -q "amd64" && command -v c++ >/dev/null 2>&1 && \
+                  ! echo __clang__ | c++ -E - | grep -q __clang__; then
+               # only clang with major version newer than 7 is supported
+               CLANG_MAJOR=`echo __clang_major__ | c++ -E - | grep -o '^[[:digit:]]'`
+               if [ "$CLANG_MAJOR" -ge "7" ]; then
+                       SUPPORT='y'
+               fi
+       fi
+}
+
+atf_test_case oom
+oom_head() {
+       atf_set "descr" "Test thread sanitizer for out-of-memory condition"
+       atf_set "require.progs" "c++ paxctl"
+}
+
+atf_test_case oom_profile
+oom_profile_head() {
+       atf_set "descr" "Test thread sanitizer for out-of-memory with profiling option"
+       atf_set "require.progs" "c++ paxctl"
+}
+atf_test_case oom_pic
+oom_pic_head() {
+       atf_set "descr" "Test thread sanitizer for out-of-memory with position independent code (PIC) flag"
+       atf_set "require.progs" "c++ paxctl"
+}
+atf_test_case oom_pie
+oom_pie_head() {
+       atf_set "descr" "Test thread sanitizer for out-of-memory with position independent execution (PIE) flag"
+       atf_set "require.progs" "c++ paxctl"
+}
+
+oom_body(){
+       cat > test.cc << EOF
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  if (size > 0 && data[0] == 'b') while (1) malloc(16*1024*1024);
+  return 0;
+}
+EOF
+
+       c++ -fsanitize=fuzzer -o test test.cc
+       paxctl +a test
+       atf_check -s ignore -o ignore -e match:"ERROR: libFuzzer: out-of-memory" ./test -rss_limit_mb=30
+}
+
+oom_profile_body(){
+       cat > test.cc << EOF
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  if (size > 0 && data[0] == 'b') while (1) malloc(16*1024*1024);
+  return 0;
+}
+EOF
+
+       c++ -fsanitize=fuzzer -o test -pg test.cc
+       paxctl +a test
+       atf_check -s ignore -o ignore -e match:"ERROR: libFuzzer: out-of-memory" ./test -rss_limit_mb=30
+}
+
+oom_pic_body(){
+       cat > test.cc << EOF
+#include <stddef.h>
+#include <stdint.h>
+int help(const uint8_t *data, size_t size);
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+    return help(data, size);
+}
+EOF
+
+       cat > pic.cc << EOF
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+int help(const uint8_t *data, size_t size) {
+  if (size > 0 && data[0] == 'b') while (1) malloc(16*1024*1024);
+  return 0;
+}
+EOF
+
+       c++ -fsanitize=fuzzer -fPIC -shared -o libtest.so pic.cc
+       c++ -o test test.cc -fsanitize=fuzzer -L. -ltest
+       paxctl +a test
+
+       export LD_LIBRARY_PATH=.
+       atf_check -s ignore -o ignore -e match:"ERROR: libFuzzer: out-of-memory" ./test -rss_limit_mb=30
+}
+oom_pie_body(){
+       
+       #check whether -pie flag is supported on this architecture
+       if ! c++ -pie -dM -E - < /dev/null 2>/dev/null >/dev/null; then 
+               atf_set_skip "c++ -pie not supported on this architecture"
+       fi
+       cat > test.cc << EOF
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  if (size > 0 && data[0] == 'b') while (1) malloc(16*1024*1024);
+  return 0;
+}
+EOF
+
+       c++ -fsanitize=fuzzer -o test -fpie -pie test.cc
+       paxctl +a test
+       atf_check -s ignore -o ignore -e match:"ERROR: libFuzzer: out-of-memory" ./test -rss_limit_mb=30
+}
+
+
+atf_test_case target_not_supported
+target_not_supported_head()
+{
+       atf_set "descr" "Test forced skip"
+}
+
+target_not_supported_body()
+{
+       atf_skip "Target is not supported"
+}
+
+atf_init_test_cases()
+{
+       test_target
+       test $SUPPORT = 'n' && {
+               atf_add_test_case target_not_supported
+               return 0
+       }
+       atf_add_test_case oom
+       atf_add_test_case oom_profile
+       atf_add_test_case oom_pie
+       atf_add_test_case oom_pic
+}
diff -r 9bafacb17eba -r 60d5f7b6fcd7 tests/usr.bin/c++/t_fuzzer_simple.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/c++/t_fuzzer_simple.sh      Thu Aug 29 16:45:25 2019 +0000
@@ -0,0 +1,187 @@
+# Copyright (c) 2018 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Yang Zheng.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR



Home | Main Index | Thread Index | Old Index