diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index a13f788e..ecbdfca1 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -581,7 +581,9 @@ def extract_symbols(file_or_filelist, objdir): # generate the symbol tuples for symbol_string, demangled_string in zip(symbol_strings, demangled_symbol_strings): - symbol = symbol_string.split(maxsplit=2)[2] + symbol_type, symbol = symbol_string.split(maxsplit=2)[1:] + if symbol_type != "T": # only look at strong symbols in the text section + continue demangled = demangled_string.split(maxsplit=2)[2] try: deffile, defline = symbol_line_mapping[symbol] diff --git a/tests/flit_cli/flit_bisect/data/tests/BisectTest.cpp b/tests/flit_cli/flit_bisect/data/tests/BisectTest.cpp index f59d1b65..75292167 100644 --- a/tests/flit_cli/flit_bisect/data/tests/BisectTest.cpp +++ b/tests/flit_cli/flit_bisect/data/tests/BisectTest.cpp @@ -84,6 +84,7 @@ #include "file1.h" #include "file2.h" #include "file3.h" +#include "file4.h" #include @@ -105,7 +106,7 @@ class BisectTest : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { FLIT_UNUSED(ti); - return file1_all() + file2_all() + file3_all(); + return file1_all() + file2_all() + file3_all() + file4_all(); } protected: diff --git a/tests/flit_cli/flit_bisect/data/tests/file4.cpp b/tests/flit_cli/flit_bisect/data/tests/file4.cpp new file mode 100644 index 00000000..c9acb952 --- /dev/null +++ b/tests/flit_cli/flit_bisect/data/tests/file4.cpp @@ -0,0 +1,114 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "file4.h" + +#include + +#include + +int file4_func1() { return 1; } +int file4_func2() { return 2; } +int file4_func3() { return 3; } +int file4_func4() { return 4; } + +template +int file4_func5_TEMPLATE_PROBLEM() { + if (std::string(FLIT_OPTL) == "-O3") { + return 5 + 10; // variability introduced = 10 + } else { + return 5; + } +} + + + +int file4_all() { + return file4_func1() + + file4_func2() + + file4_func3() + + file4_func4() + + file4_func5_TEMPLATE_PROBLEM<0>() + + file4_func5_TEMPLATE_PROBLEM<1>() + + file4_func5_TEMPLATE_PROBLEM<2>(); +} diff --git a/tests/flit_cli/flit_bisect/data/tests/file4.h b/tests/flit_cli/flit_bisect/data/tests/file4.h new file mode 100644 index 00000000..fc9baf15 --- /dev/null +++ b/tests/flit_cli/flit_bisect/data/tests/file4.h @@ -0,0 +1,95 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#ifndef FILE4_H +#define FILE4_H + +int file4_func1(); +int file4_func2(); +int file4_func3(); +int file4_func4(); +template +int file4_func5_TEMPLATE_PTOBLEM(); // variability = 10 +int file4_all(); + +#endif // FILE4_H diff --git a/tests/flit_cli/flit_bisect/tst_bisect.py b/tests/flit_cli/flit_bisect/tst_bisect.py index ec196ebb..952bf3ee 100644 --- a/tests/flit_cli/flit_bisect/tst_bisect.py +++ b/tests/flit_cli/flit_bisect/tst_bisect.py @@ -109,7 +109,10 @@ ... outstream=ostream) ... bisect_out = ostream.getvalue().splitlines() ... with open(os.path.join(temp_dir, 'bisect-01', 'bisect.log')) as fin: -... log_contents = fin.readlines() +... raw_log = fin.readlines() +... stripped_log = [line[line.index(' bisect:')+8:].rstrip() +... for line in raw_log] +... log_contents = [line for line in stripped_log if line.strip() != ''] Verify the output of flit init >>> print('\\n'.join(init_out)) # doctest:+ELLIPSIS @@ -126,29 +129,31 @@ Verify that all source files were found and output during the search >>> sorted([x.split(':')[0].split()[-1] for x in bisect_out ... if x.startswith(' Found differing source file')]) -['tests/file1.cpp', 'tests/file2.cpp', 'tests/file3.cpp'] +['tests/file1.cpp', 'tests/file2.cpp', 'tests/file3.cpp', 'tests/file4.cpp'] -Verify that the three differing sources were output in the "differing sources:" +Verify that the four differing sources were output in the "differing sources:" section >>> idx = bisect_out.index('all variability inducing source file(s):') ->>> print('\\n'.join(bisect_out[idx+1:idx+4])) +>>> print('\\n'.join(bisect_out[idx+1:idx+5])) + tests/file4.cpp (score 30.0) tests/file1.cpp (score 10.0) tests/file2.cpp (score 7.0) tests/file3.cpp (score 4.0) ->>> bisect_out[idx+4].startswith('Searching for differing symbols in:') +>>> bisect_out[idx+5].startswith('Searching for differing symbols in:') True -Verify that all three files were searched individually +Verify that all four files were searched individually >>> sorted([x.split()[-1] for x in bisect_out ... if x.startswith('Searching for differing symbols in:')]) -['tests/file1.cpp', 'tests/file2.cpp', 'tests/file3.cpp'] +['tests/file1.cpp', 'tests/file2.cpp', 'tests/file3.cpp', 'tests/file4.cpp'] -Verify all functions were identified during the symbol searches +Verify all non-templated functions were identified during the symbol searches >>> print('\\n'.join( ... sorted([' '.join(x.split()[-6:]) for x in bisect_out ... if x.startswith(' Found differing symbol on line')]))) line 100 -- file1_func3_PROBLEM() (score 2.0) line 103 -- file3_func5_PROBLEM() (score 3.0) +line 106 -- file4_all() (score 30.0) line 108 -- file1_func4_PROBLEM() (score 3.0) line 91 -- file2_func1_PROBLEM() (score 7.0) line 92 -- file1_func2_PROBLEM() (score 5.0) @@ -178,9 +183,17 @@ >>> bisect_out[idx+3].startswith(' ') False +Verify the bad symbols section for file4.cpp +>>> idx = bisect_out.index(' All differing symbols in tests/file4.cpp:') +>>> print('\\n'.join(sorted(bisect_out[idx+1:idx+2]))) + line 106 -- file4_all() (score 30.0) +>>> bisect_out[idx+2].startswith(' ') +False + Test the All differing symbols section of the output >>> idx = bisect_out.index('All variability inducing symbols:') >>> print('\\n'.join(bisect_out[idx+1:])) # doctest:+ELLIPSIS + /.../tests/file4.cpp:106 ... -- file4_all() (score 30.0) /.../tests/file2.cpp:91 ... -- file2_func1_PROBLEM() (score 7.0) /.../tests/file1.cpp:92 ... -- file1_func2_PROBLEM() (score 5.0) /.../tests/file1.cpp:108 ... -- file1_func4_PROBLEM() (score 3.0) diff --git a/tests/flit_cli/flit_bisect/tst_bisect_biggest.py b/tests/flit_cli/flit_bisect/tst_bisect_biggest.py index 19f85bbd..2b997624 100644 --- a/tests/flit_cli/flit_bisect/tst_bisect_biggest.py +++ b/tests/flit_cli/flit_bisect/tst_bisect_biggest.py @@ -118,6 +118,7 @@ ... 'tests/file1.cpp': 10.0, ... 'tests/file2.cpp': 7.0, ... 'tests/file3.cpp': 4.0, +... 'tests/file4.cpp': 0.0, ... } >>> all_symbol_scores = { @@ -136,6 +137,7 @@ ... create_symbol(3, 3, 100, False): 0.0, ... create_symbol(3, 4, 101, False): 0.0, ... create_symbol(3, 5, 103, True): 3.0, +... create_symbol(4, 1, 103, False): 0.0, ... } >>> def build_bisect_stub(makepath, directory, target='bisect', verbose=False,