object-introspection/test/integration
2023-10-09 10:41:34 -06:00
..
alignment.toml Update to clang/llvm 15 (#342) 2023-09-14 06:02:32 -07:00
anonymous.toml oil v2 2023-08-23 15:59:53 +01:00
arrays.toml oil v2 2023-08-23 15:59:53 +01:00
bitfields.toml TypeGraph: Support bitfields 2023-07-05 13:23:23 +01:00
capture_keys.toml folly::sorted_vector_map: Add key-capture support 2023-09-29 11:21:41 -07:00
CMakeLists.txt oil v2 2023-08-23 15:59:53 +01:00
cycles.toml oil v2 2023-08-23 15:59:53 +01:00
enums_params.toml oil v2 2023-08-23 15:59:53 +01:00
enums.toml codegen: generate enums as enum class 2023-09-20 18:13:45 +01:00
fbstring.toml Implement Container V2 for fbstring 2023-09-27 18:16:36 -07:00
folly_f14_fast_map.toml Implement Container V2 for F14FastMap 2023-09-07 18:47:09 +02:00
folly_f14_fast_set.toml Fix exclusive_size for F14FastSet 2023-10-09 10:41:34 -06:00
folly_f14_node_map.toml Implement Container V2 for F14NodeMap 2023-09-07 18:47:09 +02:00
folly_f14_node_set.toml Fix exclusive_size for F14NodeSet 2023-10-09 10:41:34 -06:00
folly_f14_value_map.toml Fix exclusive_size for F14ValueMap 2023-10-09 10:41:34 -06:00
folly_f14_value_set.toml Fix exclusive_size for F14ValueSet 2023-10-09 10:41:34 -06:00
folly_f14_vector_map.toml Implement Container V2 for F14VectorMap 2023-09-07 18:47:09 +02:00
folly_f14_vector_set.toml Fix exclusive_size for F14VectorSet 2023-10-09 10:41:34 -06:00
folly_shims.cpp Implement Container V2 for F14VectorMap 2023-09-07 18:47:09 +02:00
folly_small_vector.toml Implement Container V2 for folly::small_vector 2023-09-08 16:34:34 +02:00
folly_sorted_vector_map.toml oil v2 2023-08-23 15:59:53 +01:00
gen_tests.py support 0 to many config files (#371) 2023-10-02 14:06:39 -06:00
ignored.toml oil v2 2023-08-23 15:59:53 +01:00
inheritance_access.toml oil v2 2023-08-23 15:59:53 +01:00
inheritance_multiple.toml oil v2 2023-08-23 15:59:53 +01:00
inheritance_polymorphic_diamond.toml features: clean up old flags 2023-06-23 11:25:43 +01:00
inheritance_polymorphic_non_dynamic_base.toml oil v2 2023-08-23 15:59:53 +01:00
inheritance_polymorphic.toml features: clean up old flags 2023-06-23 11:25:43 +01:00
multi_arg.toml oil v2 2023-08-23 15:59:53 +01:00
namespaces.toml oil v2 2023-08-23 15:59:53 +01:00
packed.toml Initial commit 2022-12-19 06:37:51 -08:00
padding.toml oil v2 2023-08-23 15:59:53 +01:00
pointers_function.toml oil v2 2023-08-23 15:59:53 +01:00
pointers_incomplete.toml oil v2 2023-08-23 15:59:53 +01:00
pointers.toml oil v2 2023-08-23 15:59:53 +01:00
primitives.toml integration/primitives.toml: Add char8_t test 2023-02-21 11:59:16 -08:00
README.md integration: add GLOB with CONFIGURE_DEPENDS to pick up files 2023-06-29 15:47:06 +01:00
references.toml add issue references to every skipped test 2023-01-04 17:56:37 +00:00
runner_common.cpp support 0 to many config files (#371) 2023-10-02 14:06:39 -06:00
runner_common.h support 0 to many config files (#371) 2023-10-02 14:06:39 -06:00
simple.toml oil v2 2023-08-23 15:59:53 +01:00
sorted_vector_set.toml Implement Container V2 for folly::sorted_vector_set 2023-09-27 19:06:20 -07:00
std_array.toml oil v2 2023-08-23 15:59:53 +01:00
std_conditional.toml oil v2 2023-08-23 15:59:53 +01:00
std_deque_del_allocator.toml oil v2 2023-08-23 15:59:53 +01:00
std_deque.toml oil v2 2023-08-23 15:59:53 +01:00
std_list_del_allocator.toml oil v2 2023-08-23 15:59:53 +01:00
std_map_custom_comparator.toml Implement Container V2 for std::map 2023-08-25 15:13:55 +02:00
std_multimap_custom_comparator.toml Implement Container V2 for std::multimap 2023-08-25 16:07:10 +02:00
std_multiset_custom_comparator.toml Implement Container V2 for std::multiset 2023-08-25 16:07:10 +02:00
std_optional.toml Add OILv2 tests for std::optional 2023-08-31 20:07:32 +02:00
std_pair.toml make StubbedPointer an explicit C++ type 2023-09-22 11:49:50 +01:00
std_priority_queue.toml oil v2 2023-08-23 15:59:53 +01:00
std_queue.toml oil v2 2023-08-23 15:59:53 +01:00
std_reference_wrapper.toml oil v2 2023-08-23 15:59:53 +01:00
std_set_custom_comparator.toml std::set implementation for Container V2 2023-08-24 13:57:27 +02:00
std_smart_ptr.toml Implement Container V2 for std::shared_ptr 2023-08-31 20:07:32 +02:00
std_stack.toml oil v2 2023-08-23 15:59:53 +01:00
std_string.toml oil v2 2023-08-23 15:59:53 +01:00
std_tuple.toml oil v2 2023-08-23 15:59:53 +01:00
std_unordered_map_custom_operator.toml Implement Container V2 for std::unordered_map 2023-08-30 18:45:00 +02:00
std_unordered_map.toml add issue references to every skipped test 2023-01-04 17:56:37 +00:00
std_unordered_multimap_custom_operator.toml Implement Container V2 for std::unordered_multimap 2023-08-30 18:45:00 +02:00
std_unordered_multiset_custom_operator.toml Implement Container V2 for std::unordered_multiset 2023-08-30 18:45:00 +02:00
std_unordered_set_custom_operator.toml Implement Container V2 for std::unordered_set 2023-08-30 18:45:00 +02:00
std_variant.toml oil v2 2023-08-23 15:59:53 +01:00
std_vector_del_allocator.toml oil v2 2023-08-23 15:59:53 +01:00
std_vector.toml oil v2 2023-08-23 15:59:53 +01:00
templates.toml oil v2 2023-08-23 15:59:53 +01:00
thrift_isset_missing.toml oil v2 2023-08-23 15:59:53 +01:00
thrift_isset.toml oil v2 2023-08-23 15:59:53 +01:00
thrift_namespaces.toml oil v2 2023-08-23 15:59:53 +01:00
thrift_unions.toml oil v2 2023-08-23 15:59:53 +01:00
typedefed_parent.toml oil v2 2023-08-23 15:59:53 +01:00
typedefs.toml oil v2 2023-08-23 15:59:53 +01:00
unions.toml oil v2 2023-08-23 15:59:53 +01:00

Integration Tests

This directory contains test definition files for OI's integration tests.

Running tests

There are a number of ways to run these integration tests.

  1. Run the integration_test_runner executable directly. This provides some additional options to aid debugging:

    • --verbose Verbose output
    • --preserve Do not clean up files generated by OID after tests are finished
    • --force Run tests that have been marked as "skipped"

    e.g.

    build/test/integration/integration_test_runner --gtest_filter=OidIntegration.primitives_int --verbose
    
  2. Run a number of the integration tests in parallel:

    ctest --test-dir build/test/integration -j$(nproc) [--tests-regex <regex>]
    

Additional command line arguments can be passed to oid by setting the OID_TEST_ARGS environment variable, e.g.:

OID_TEST_ARGS="-fmy-new-feature" build/test/integration/integration_test_runner
OID_TEST_ARGS="-Fold-feature" ctest --test-dir build/test/integration

Adding tests

Create a new test definition file in this directory and populate it as needed. See Test Definition Format for details. It will be automatically picked up by CMake on your next build.

Test Definition Format

Test definitions are stored in the TOML file format.

Example:

includes = ["vector", "unordered_map"]
definitions = '''
  struct Foo {
    std::vector<int> v;
  };
  using Bar = std::unordered_map<int, int>;
'''
[cases]
  [cases.my_first_test_case]
    param_types = ["const Foo&", "const Bar&"]
    setup = '''
      Foo foo;
      foo.v = {4,5,6};
      Bar bar;
      bar[2] = 3;
      return {foo, bar};
    '''
    expect_json = '{"staticSize":4,"dynamicSize":32}'
  [cases.another_test_case]
    param_types = ["int"]
    setup = 'return 123;'

Details

  • includes

    Header files required for this test.

    Example:

    includes = ["vector", "unordered_map"]
    
  • definitions

    C++ type definitions required for a test can be defined here.

    Anything defined in this section will be automatically wrapped in a namespace and will be private to this test.

    Example:

    definitions = '''
      struct Foo {
        std::vector<int> v;
      };
      using Bar = std::unordered_map<int, int>;
    '''
    
  • thrift_definitions

    Thrift type definitions can be specified here. These will be passed to the Thrift compiler which will generate C++ code from them.

    CAUTION: Generated Thrift types are not wrapped in a namespace, so type names must be globally unique between all tests.

    Example:

    thrift_definitions = '''
      struct MyThriftStruct {
        1: optional i32 a;
        2: optional i32 b;
      }
    '''
    
  • raw_definitions

    This section allows specifying of arbitrary C++ code which will be directly copied into the target program's source without being wrapped in a namespace.

    It should not be used for most tests. The purpose is to allow defining code required for a specific test to compile, avoiding the need to add new dependencies to the build system for one-off tests.

  • cases Required

    A list of individual test cases, each with their own setup, OI probe definition and expected results, but sharing any type definitions created in this test file.

    Test cases should be grouped into related areas and put into shared test files.

    • param_types Required

      Paramter types of the function to probe.

      oid does not have complete support for probing pass-by-value parameters, so it is recommended to define all parameters as reference or pointer types.

      Example:

      param_types = ["const std::vector<int>&", "const Foo&"]
      
    • arg_types

      Types of the arguments being passed to the probed function. Defaults to param_types with const, volatile and references removed.

      It is only necessary to specify arg_types when they will differ from the parameter types expected by the probed function. This can be useful for testing inheritance.

      Example:

      param_types = ["BaseClass *"]
      arg_types = ["DerivedClass"]
      
    • setup Required

      A snippit of C++ code which creates and returns values to be passed to the function being probed as a part of this test case. The returned value should be a tuple of param_types, although the curly brakcets/braces can be omitted in most cases when there is only a single value in the tuple.

      Example:

      setup = '''
        std::vector<int> ret = {1,2,3};
        return {ret, Foo(1)};
      '''
      
    • type

      OI probe type. Defaults to entry.

      Example:

      type = "return"
      
    • args

      Comma separated list of arguments to introspect. Defaults to arg0.

      Example:

      args = "arg0,arg1"
      
    • target_function

      Symbol of the target function to be traced, when the auto-generated target function is not sufficient.

      The fields param_types and setup are no longer required if target_function is defined.

      Example:

      target_function = "my_function"
      

      Implies oil_disable.

    • cli_options

      Additional command line arguments passed to oid.

      Example:

      cli_options = ["-fchase-raw-pointers"]
      
    • skip, oid_skip, oil_skip

      Skip running this test for oid and/or oil.

      Pass in a string to provide a reason for skipping the test.

      Example:

      oid_skip = "oid support not implemented yet"
      
    • oil_disable

      Disable this test for oil.

      When a test doesn't make sense for oil, disable it rather than skipping it, to avoid it showing up in the aggregate test results entirely.

      Example:

      oil_skip = "oil can't chase raw pointers safely"
      
    • expect_oid_exit_code, expect_oil_exit_code

      Exit code expected from OI. Defaults to 0.

      Example:

      expect_oid_exit_code = 6
      
    • expect_json

      JSON expected to match results from OI.

      Only keys which appear in these expected results are used for comparison. This means that irrelevant or non-reproducable keys can be omitted and they will be ignored. Missing keys in the actual results will still cause test failures.

      Example:

      expect_json = '{"staticSize":4,"dynamicSize":0}'
      

      To ensure that a given key does not appear in the results, the special NOT key can be used, with the value set to the undesired key's name.

      This example checks that the JSON result does not contain the key "members":

      expect_json = '{"NOT":"members"}'
      

      The NOT key can also be used to check that a given key's value is not equal to some expected value.

      This example checks that the result has a key named pointer, but that its value is not equal to 0:

      expect_json = '{"NOT":{"pointer":0}}'
      
    • expect_stdout

      Regex expected to match OI's stdout.

      Example:

      expect_stdout = ".*SUCCESS.*"
      
    • expect_stderr

      Regex expected to match OI's stderr.

      Example:

      expect_stderr = ".*Successfully detached from pid.*"
      
    • expect_not_stdout

      Regex expected to not match OI's stdout.

      Example:

      expect_not_stdout = "ABC"
      
    • expect_not_stderr

      Regex expected to not match OI's stderr.

      Example:

      expect_not_stderr = ".*ERROR.*"