Files
lifting-bits-mcsema/tests/integration_tests/src/struct_func_ptr.cpp
T
Aiethel d42db800a4 Test suite v2 (#589)
* Parse flavors

* Batch folder is now created/deleted properly

* Shared libraries as symlinks in special dir

* Simple README file

* Get binary info

* Simple cfg retrieval

* Lifter has path to cfg as argument

* Flags for eventual evaluation

* Check policy and presence of cfg file

* Print results of getting the cfgs

* Check of batch sanity fix

* run_test cli parsing

* Add abi_libraries directory parsing

* Shared libraries directory parsing

* Lift and recompile

* Before actual test implementation

* Playground for testing

* Actual testing

* Split test cases on per binary bases

* Add some commits

* Result print

* Enhance README.txt

* Populate.py to copy needed binaries

* Add short decsription of populate.py

* Support flavor all

* add ida frontend implementation

* Basic tag files

* Basic inputs

* Missing comma

* Change inputs handling

* Separate function for copy files

* Naming convention

* Handle missing test case class

* Create bin if it is missing

* Create so_dir if it is missing

* Remove not used cmd argument

* Add several more test_suites

* ida frontend lift function can now be selected

* Smarter tests

* BasicTest does not need setUp

* Prevent system-wide installed binaries from being run instead of tested

* Simple comment

* Pass rest of are passed to lift

* Fix parser error with unspecified lift_args

* Variable name

* Change default interpreter to python3

* Fix optional argument parsing for the subsequent lift

* typo in mcsema-disass

* More details in README

* Simplify usage of IDA frontend

* ida frontend stores logs

* Add script to compile programs and generate tags if desired

* Year on copyright

* Add hello world src examples of tests.

* Add test addition example to README

* Correct extension for log files

* Basic linker flags

* Fix crash if file in bin is missing when tag is present

* Bunch of test files

* Empty runs

* Test_suite name should have maxsplit=1

* Dynamically create test_suites for src programs from definitions

* Define cases

* Stdin

* Split tests into another file

* WIP: stdin from string

* Another string to be matched if binary is pie

* Fix typo in test case

* Add color support

* Improve stdout output

* Add wrappers to make colors more use friendly

* Move object representation of test results into separate file

* Add magneta

* Cleaner verbose output

* Log partial results, so they can be dumped into file later for comparison

* Replace usage of internals of color.Colors

* Refactor how constants are hidden in Colors

* Add load/save test results into json

* Simple printer of multiple results

* result_data.compare() now takes formatter as argument which handles all printing

* result_data compare() code cleanup

* Missing closing bracket in get_cfg

* Test cases now correctly process stdin

* Add option to save log as json

* Move global variable input_dir into correct module

* Add missing suites for files compiled from sources

* Compile does not crash when tags are not being stubbed

* Fix passing stdin into Popen - input is bytes instead of str

* Some tests no longer print floats

* populate: Add color support

* run_tests: Multithread support

* run_tests: Introduces option to specify number of threads to use

* get_cfg: Introduces option to specify number of threads to use

* Update README with compile.py information

* Change --lib_dir to --runtime_lib to avoid llvm version problems

* WIP: Set default compiler to clang-8

* Logs are now stored inside batch_name_cfg/logs

* Fix bug in log file filename generation

* get_cfg: If all is specified as flavor, even empty tag files are selected

* Changed run_tests.py --libc_dir to --abi_lib_dir to match mcsema-lift naming conventions

* run_test: Timeout is now set to 5sec per test

* run_tests: timeout is static attribute of BaseTest.

* run_tests: Expand grep tests

* run_tests: timeout is now logged as type of test result

* src: Add test for global ctors/dtors.

* src: Compile script can now use user-defined compilators

* run: Add runners for global ctor/dtor tests.

* compile: TAGS can now be specified as first line in src file

* src: Add TAGS to source files

* compile: Source files can now contain more complex header

* compile: Config is now responsible for whole process

* src: reflect changes in compile script

* Missing copyright header

* Add util script

* populate: Reflect changes in tags structure

* get_cfg: Replace flavors by tags to be consistent

* get_cfg: Reflect changes in tags structure

* run: Parse configs

* run: Rework lift to use class instead of random stuff everywhere

* run: Removed unittest

* run: Remove tests.py

* src: Add headers to src tests

* run: Obliterate last remnants of tests.py

* Update README to reflect changes

* Change README from plaintext to markdown

* Update .remill_commit_id

* Update .remill_commit_id
2019-10-27 18:54:22 -04:00

48 lines
1.1 KiB
C++

/* TAGS: min cpp */
/* TEST: */
/* STDIN: 4\n4\n */
/* TEST: */
/* STDIN: 5\n5\n */
/*
* Copyright (c) 2018 Trail of Bits, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>
#include <string>
template< typename F >
struct Holder {
F a;
F b;
};
int foo( std::string str ) {
std::cout << "Foo: " << str << std::endl;
return 1;
}
int boo( std::string str ) {
std::cout << "Boo: " << str << std::endl;
return 2;
}
int main() {
Holder< int(*)(std::string) > h { foo, boo };
int a;
std::cin >> a;
if ( a % 2 ) h.a( "hello" );
else h.b( "world" );
}