From da6850916b4501c133c02263f12147dcbb1f23f1 Mon Sep 17 00:00:00 2001 From: Dominik Loidolt <dominik.loidolt@univie.ac.at> Date: Sat, 16 Mar 2024 23:25:22 +0100 Subject: [PATCH] Refactor testing setup --- .lcovrc | 1 + lib/rdcu_compress/cmp_rdcu.c | 1 + lib/rdcu_compress/cmp_rdcu_testing.h | 30 +++ meson.build | 5 +- programs/meson.build | 2 +- programs/rdcu_pkt_to_file.c | 4 +- .../pcg-c-basic-Port-to-C89.patch | 206 ++++++++++++++++++ .../packagefiles/pcg-c-basic/meson.build | 5 +- subprojects/pcg-c-basic.wrap | 1 + subprojects/unity.wrap | 8 +- test/cmp_data_types/meson.build | 13 +- test/cmp_decmp/meson.build | 13 +- test/cmp_entity/meson.build | 13 +- test/cmp_icu/meson.build | 13 +- test/cmp_max_used_bits/meson.build | 13 +- test/cmp_rdcu_cfg/meson.build | 13 +- test/decmp/meson.build | 13 +- test/meson.build | 31 ++- test/test_common/test_common.c | 1 + test/tools/generate_test_runner.rb | 37 ++-- 20 files changed, 308 insertions(+), 115 deletions(-) create mode 100644 .lcovrc create mode 100644 lib/rdcu_compress/cmp_rdcu_testing.h create mode 100644 subprojects/packagefiles/pcg-c-basic-Port-to-C89.patch diff --git a/.lcovrc b/.lcovrc new file mode 100644 index 0000000..29a0562 --- /dev/null +++ b/.lcovrc @@ -0,0 +1 @@ +lcov_excl_br_line = LCOV_EXCL_BR_LINE|cpu_to_be16|cpu_to_be32|cpu_to_be64|be16_to_cpu|be32_to_cpu|be64_to_cpu diff --git a/lib/rdcu_compress/cmp_rdcu.c b/lib/rdcu_compress/cmp_rdcu.c index 6bfbffb..e95f535 100644 --- a/lib/rdcu_compress/cmp_rdcu.c +++ b/lib/rdcu_compress/cmp_rdcu.c @@ -31,6 +31,7 @@ #include "../common/cmp_debug.h" #include "../common/cmp_support.h" +#include "cmp_rdcu_testing.h" #include "cmp_rdcu_cfg.h" #include "rdcu_ctrl.h" #include "rdcu_rmap.h" diff --git a/lib/rdcu_compress/cmp_rdcu_testing.h b/lib/rdcu_compress/cmp_rdcu_testing.h new file mode 100644 index 0000000..56f2409 --- /dev/null +++ b/lib/rdcu_compress/cmp_rdcu_testing.h @@ -0,0 +1,30 @@ +/** + * @file cmp_rdcu_testing.h + * @author Dominik Loidolt (dominik.loidolt@univie.ac.at) + * @date 2024 + * + * @copyright GPLv2 + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * @brief function to test RDCU compression + * @warning not indented for production use; only for testing + */ + +#ifndef CMP_RDCU_TESTING_H +#define CMP_RDCU_TESTING_H + +#include "../common/cmp_support.h" + +int rdcu_start_compression(void); +int rdcu_inject_edac_error(const struct cmp_cfg *cfg, uint32_t addr); +int rdcu_compress_data_parallel(const struct cmp_cfg *cfg, + const struct cmp_info *last_info); + +#endif /* CMP_RDCU_TESTING_H */ diff --git a/meson.build b/meson.build index 0bc9844..c93b423 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('cmp_tool', 'c', version : '0.12-b3', - meson_version : '>= 0.56', + meson_version : '>= 0.63', license : 'GPL-2.0', default_options : [ 'warning_level=3', @@ -19,6 +19,7 @@ feature_argument_input_mode = get_option('argument_input_mode') # Compiler flags +add_global_arguments('-Wno-long-long', language : 'c') cc_flags = ['-DDEBUGLEVEL=@0@'.format(debug_level)] if use_debug debug_flags = [ @@ -36,7 +37,7 @@ if use_debug '-Wfloat-equal', '-Wwrite-strings', '-Wold-style-definition', - '-Waggregate-return', +# '-Waggregate-return', '-Wmissing-declarations', '-Wmissing-include-dirs' ] diff --git a/programs/meson.build b/programs/meson.build index ad9de48..4cb183c 100644 --- a/programs/meson.build +++ b/programs/meson.build @@ -24,5 +24,5 @@ cmp_tool_exe = executable('cmp_tool', sources : cmp_tool_src, include_directories : incdir, link_with : cmp_lib, - install : 'true' + install : true ) diff --git a/programs/rdcu_pkt_to_file.c b/programs/rdcu_pkt_to_file.c index 28df657..bc8734f 100644 --- a/programs/rdcu_pkt_to_file.c +++ b/programs/rdcu_pkt_to_file.c @@ -34,9 +34,7 @@ #include <rdcu_rmap.h> #include <rdcu_ctrl.h> #include <rdcu_cmd.h> - - -int rdcu_compress_data_parallel(const struct cmp_cfg *cfg, const struct cmp_info *last_info); +#include <cmp_rdcu_testing.h> /* Name of directory were the RMAP packages are stored */ diff --git a/subprojects/packagefiles/pcg-c-basic-Port-to-C89.patch b/subprojects/packagefiles/pcg-c-basic-Port-to-C89.patch new file mode 100644 index 0000000..e74f41a --- /dev/null +++ b/subprojects/packagefiles/pcg-c-basic-Port-to-C89.patch @@ -0,0 +1,206 @@ +From c5b6186b22b939f131c8f098fce3e4338f780c58 Mon Sep 17 00:00:00 2001 +From: Dominik Loidolt <dominik.loidolt@univie.ac.at> +Date: Fri, 15 Mar 2024 18:21:32 +0100 +Subject: [PATCH] Port to C89 + +--- + pcg_basic.c | 78 ++++++++++++++++++++++++++++++----------------------- + pcg_basic.h | 41 +++++++++++++++------------- + 2 files changed, 66 insertions(+), 53 deletions(-) + +diff --git a/pcg_basic.c b/pcg_basic.c +index 8c2fd0d..79f1d0a 100644 +--- a/pcg_basic.c ++++ b/pcg_basic.c +@@ -30,14 +30,16 @@ + + #include "pcg_basic.h" + +-// state for global RNGs ++/* state for global RNGs */ + + static pcg32_random_t pcg32_global = PCG32_INITIALIZER; + +-// pcg32_srandom(initstate, initseq) +-// pcg32_srandom_r(rng, initstate, initseq): +-// Seed the rng. Specified in two parts, state initializer and a +-// sequence selection constant (a.k.a. stream id) ++/* ++ * pcg32_srandom(initstate, initseq) ++ * pcg32_srandom_r(rng, initstate, initseq): ++ * Seed the rng. Specified in two parts, state initializer and a ++ * sequence selection constant (a.k.a. stream id) ++ */ + + void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, uint64_t initseq) + { +@@ -53,54 +55,62 @@ void pcg32_srandom(uint64_t seed, uint64_t seq) + pcg32_srandom_r(&pcg32_global, seed, seq); + } + +-// pcg32_random() +-// pcg32_random_r(rng) +-// Generate a uniformly distributed 32-bit random number ++/* ++ * pcg32_random(void) ++ * pcg32_random_r(rng) ++ * Generate a uniformly distributed 32-bit random number ++ */ + + uint32_t pcg32_random_r(pcg32_random_t* rng) + { + uint64_t oldstate = rng->state; +- rng->state = oldstate * 6364136223846793005ULL + rng->inc; +- uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u; ++ uint32_t xorshifted = (uint32_t)(((oldstate >> 18u) ^ oldstate) >> 27u); + uint32_t rot = oldstate >> 59u; ++ ++ rng->state = oldstate * 6364136223846793005ULL + rng->inc; + return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); + } + +-uint32_t pcg32_random() ++uint32_t pcg32_random(void) + { + return pcg32_random_r(&pcg32_global); + } + + +-// pcg32_boundedrand(bound): +-// pcg32_boundedrand_r(rng, bound): +-// Generate a uniformly distributed number, r, where 0 <= r < bound ++/* ++ * pcg32_boundedrand(bound): ++ * pcg32_boundedrand_r(rng, bound): ++ * Generate a uniformly distributed number, r, where 0 <= r < bound ++ */ + + uint32_t pcg32_boundedrand_r(pcg32_random_t* rng, uint32_t bound) + { +- // To avoid bias, we need to make the range of the RNG a multiple of +- // bound, which we do by dropping output less than a threshold. +- // A naive scheme to calculate the threshold would be to do +- // +- // uint32_t threshold = 0x100000000ull % bound; +- // +- // but 64-bit div/mod is slower than 32-bit div/mod (especially on +- // 32-bit platforms). In essence, we do +- // +- // uint32_t threshold = (0x100000000ull-bound) % bound; +- // +- // because this version will calculate the same modulus, but the LHS +- // value is less than 2^32. ++ /* To avoid bias, we need to make the range of the RNG a multiple of ++ * bound, which we do by dropping output less than a threshold. ++ * A naive scheme to calculate the threshold would be to do ++ * ++ * uint32_t threshold = 0x100000000ull % bound; ++ * ++ * but 64-bit div/mod is slower than 32-bit div/mod (especially on ++ * 32-bit platforms). In essence, we do ++ * ++ * uint32_t threshold = (0x100000000ull-bound) % bound; ++ * ++ * because this version will calculate the same modulus, but the LHS ++ * value is less than 2^32. ++ */ + + uint32_t threshold = -bound % bound; + +- // Uniformity guarantees that this loop will terminate. In practice, it +- // should usually terminate quickly; on average (assuming all bounds are +- // equally likely), 82.25% of the time, we can expect it to require just +- // one iteration. In the worst case, someone passes a bound of 2^31 + 1 +- // (i.e., 2147483649), which invalidates almost 50% of the range. In +- // practice, bounds are typically small and only a tiny amount of the range +- // is eliminated. ++ /* ++ * Uniformity guarantees that this loop will terminate. In practice, it ++ * should usually terminate quickly; on average (assuming all bounds are ++ * equally likely), 82.25% of the time, we can expect it to require just ++ * one iteration. In the worst case, someone passes a bound of 2^31 + 1 ++ * (i.e., 2147483649), which invalidates almost 50% of the range. In ++ * practice, bounds are typically small and only a tiny amount of the range ++ * is eliminated. ++ */ + for (;;) { + uint32_t r = pcg32_random_r(rng); + if (r >= threshold) +diff --git a/pcg_basic.h b/pcg_basic.h +index e2b526a..63ae2db 100644 +--- a/pcg_basic.h ++++ b/pcg_basic.h +@@ -31,48 +31,51 @@ + #ifndef PCG_BASIC_H_INCLUDED + #define PCG_BASIC_H_INCLUDED 1 + +-#include <inttypes.h> ++#include <stdint.h> + +-#if __cplusplus ++#ifdef __cplusplus + extern "C" { + #endif + +-struct pcg_state_setseq_64 { // Internals are *Private*. +- uint64_t state; // RNG state. All values are possible. +- uint64_t inc; // Controls which RNG sequence (stream) is +- // selected. Must *always* be odd. ++struct pcg_state_setseq_64 { /* Internals are *Private*. */ ++ uint64_t state; /* RNG state. All values are possible. */ ++ uint64_t inc; /* Controls which RNG sequence (stream) is */ ++ /* selected. Must *always* be odd. */ + }; + typedef struct pcg_state_setseq_64 pcg32_random_t; + +-// If you *must* statically initialize it, here's one. ++/* If you *must* statically initialize it, here's one. */ + + #define PCG32_INITIALIZER { 0x853c49e6748fea9bULL, 0xda3e39cb94b95bdbULL } + +-// pcg32_srandom(initstate, initseq) +-// pcg32_srandom_r(rng, initstate, initseq): +-// Seed the rng. Specified in two parts, state initializer and a +-// sequence selection constant (a.k.a. stream id) ++/* pcg32_srandom(initstate, initseq) ++ * pcg32_srandom_r(rng, initstate, initseq): ++ * Seed the rng. Specified in two parts, state initializer and a ++ * sequence selection constant (a.k.a. stream id) ++ */ + + void pcg32_srandom(uint64_t initstate, uint64_t initseq); + void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, + uint64_t initseq); + +-// pcg32_random() +-// pcg32_random_r(rng) +-// Generate a uniformly distributed 32-bit random number ++/* pcg32_random() ++ * pcg32_random_r(rng) ++ * Generate a uniformly distributed 32-bit random number ++ */ + + uint32_t pcg32_random(void); + uint32_t pcg32_random_r(pcg32_random_t* rng); + +-// pcg32_boundedrand(bound): +-// pcg32_boundedrand_r(rng, bound): +-// Generate a uniformly distributed number, r, where 0 <= r < bound ++/* pcg32_boundedrand(bound): ++ * pcg32_boundedrand_r(rng, bound): ++ * Generate a uniformly distributed number, r, where 0 <= r < bound ++ */ + + uint32_t pcg32_boundedrand(uint32_t bound); + uint32_t pcg32_boundedrand_r(pcg32_random_t* rng, uint32_t bound); + +-#if __cplusplus ++#ifdef __cplusplus + } + #endif + +-#endif // PCG_BASIC_H_INCLUDED ++#endif /* PCG_BASIC_H_INCLUDED */ +-- +2.44.0 + diff --git a/subprojects/packagefiles/pcg-c-basic/meson.build b/subprojects/packagefiles/pcg-c-basic/meson.build index efe83eb..9724a0b 100644 --- a/subprojects/packagefiles/pcg-c-basic/meson.build +++ b/subprojects/packagefiles/pcg-c-basic/meson.build @@ -1,13 +1,14 @@ project('pcg-c-basic', 'c', version: '0.9', - license: 'Apache 2.0', + license: 'Apache 2.0' ) inc = include_directories('.') libpcg_basic = static_library('pcg_basic', 'pcg_basic.c', include_directories : inc, - install : true) + install : true +) libpcg_basic_dep = declare_dependency(include_directories : inc, link_with : libpcg_basic) diff --git a/subprojects/pcg-c-basic.wrap b/subprojects/pcg-c-basic.wrap index 1b24864..f9a0140 100644 --- a/subprojects/pcg-c-basic.wrap +++ b/subprojects/pcg-c-basic.wrap @@ -4,3 +4,4 @@ source_url = https://www.pcg-random.org/downloads/pcg-c-basic-0.9.zip source_filename = pcg-c-basic-0.9.zip source_hash = 143f9cc0edc7e81064bde5ed6c5f16cbf7ca2f373d35543286f5fe4475a2eff1 patch_directory = pcg-c-basic +diff_files = pcg-c-basic-Port-to-C89.patch diff --git a/subprojects/unity.wrap b/subprojects/unity.wrap index 8cc4883..29246ac 100644 --- a/subprojects/unity.wrap +++ b/subprojects/unity.wrap @@ -1,8 +1,8 @@ [wrap-file] -directory = Unity-2.5.2 -source_url = https://github.com/ThrowTheSwitch/Unity/archive/refs/tags/v2.5.2.tar.gz -source_filename = Unity-2.5.2.tar.gz -source_hash = 3786de6c8f389be3894feae4f7d8680a02e70ed4dbcce36109c8f8646da2671a +directory = Unity-2.6.0 +source_url = https://github.com/ThrowTheSwitch/Unity/archive/refs/tags/v2.6.0.tar.gz +source_filename = Unity-2.6.0.tar.gz +source_hash = aa4c9fb1ae5fc5242f914c65f3557e817e40cb37f04a31e5ff76d1ab89dbf674 [provide] unity = unity_dep diff --git a/test/cmp_data_types/meson.build b/test/cmp_data_types/meson.build index 17ff50e..d84e4b6 100644 --- a/test/cmp_data_types/meson.build +++ b/test/cmp_data_types/meson.build @@ -1,12 +1 @@ -test_case = files('test_cmp_data_types.c') -test_runner = test_runner_generator.process(test_case) - -test_cmp_data_types = executable('test_cmp_data_types', - test_case, test_runner, - include_directories : incdir, - link_with : cmp_lib, - dependencies : unity_dep, - build_by_default : false -) - -test('Compression Data Types Unit Tests', test_cmp_data_types) +test_cases += [[files('test_cmp_data_types.c'), 'Compression Data Types Unit Tests']] diff --git a/test/cmp_decmp/meson.build b/test/cmp_decmp/meson.build index 33a6f47..7feff7a 100644 --- a/test/cmp_decmp/meson.build +++ b/test/cmp_decmp/meson.build @@ -1,12 +1 @@ -test_case = files('test_cmp_decmp.c') -test_runner = test_runner_generator.process(test_case) - -test_cmp_decmp = executable('test_cmp_decmp', - test_case, test_runner, - include_directories : incdir, - link_with : [cmp_lib, test_common_lib], - dependencies : unity_dep, - build_by_default : false -) - -test('Compression Decompression Unit Tests', test_cmp_decmp) +test_cases += [[files('test_cmp_decmp.c'), 'Compression Decompression Unit Tests']] diff --git a/test/cmp_entity/meson.build b/test/cmp_entity/meson.build index 98fedca..e127171 100644 --- a/test/cmp_entity/meson.build +++ b/test/cmp_entity/meson.build @@ -1,12 +1 @@ -test_case = files('test_cmp_entity.c') -test_runner = test_runner_generator.process(test_case) - -test_cmp_entity = executable('test_cmp_entity', - test_case, test_runner, - include_directories : incdir, - link_with : cmp_lib, - dependencies : unity_dep, - build_by_default : false -) - -test('Compression Entity Unit Tests', test_cmp_entity) +test_cases += [[files('test_cmp_entity.c'), 'Compression Entity Unit Tests']] diff --git a/test/cmp_icu/meson.build b/test/cmp_icu/meson.build index f92d5ee..7bc5eef 100644 --- a/test/cmp_icu/meson.build +++ b/test/cmp_icu/meson.build @@ -1,12 +1 @@ -test_case = files('test_cmp_icu.c') -test_runner = test_runner_generator.process(test_case) - -test_cmp_icu = executable('test_cmp_icu', - test_case, test_runner, - include_directories : incdir, - link_with : [cmp_lib, test_common_lib], - dependencies : unity_dep, - build_by_default : false -) - -test('cmp_icu Unit Tests', test_cmp_icu) +test_cases += [[files('test_cmp_icu.c'), 'cmp_icu Unit Tests']] diff --git a/test/cmp_max_used_bits/meson.build b/test/cmp_max_used_bits/meson.build index a7c001e..b863442 100644 --- a/test/cmp_max_used_bits/meson.build +++ b/test/cmp_max_used_bits/meson.build @@ -1,12 +1 @@ -test_case = files('test_cmp_max_used_bits_list.c') -test_runner = test_runner_generator.process(test_case) - -test_cmp_max_used_bits_list = executable('test_cmp_max_used_bits_list', - test_case, test_runner, - include_directories : incdir, - link_with : cmp_lib, - dependencies : unity_dep, - build_by_default : false -) - -test('max_used_bits List Unit Tests', test_cmp_max_used_bits_list) +test_cases += [[files('test_cmp_max_used_bits_list.c'), 'max_used_bits List Unit Tests']] diff --git a/test/cmp_rdcu_cfg/meson.build b/test/cmp_rdcu_cfg/meson.build index 3d01fd0..7242590 100644 --- a/test/cmp_rdcu_cfg/meson.build +++ b/test/cmp_rdcu_cfg/meson.build @@ -1,12 +1 @@ -test_case = files('test_cmp_rdcu_cfg.c') -test_runner = test_runner_generator.process(test_case) - -test_cmp_rdcu_cfg = executable('test_cmp_rdcu_cfg', - test_case, test_runner, - include_directories : incdir, - link_with : cmp_lib, - dependencies : unity_dep, - build_by_default : false -) - -test('Hardware Compressor Configuration Tests', test_cmp_rdcu_cfg) +test_cases += [[files('test_cmp_rdcu_cfg.c'), 'Hardware Compressor Configuration Tests']] diff --git a/test/decmp/meson.build b/test/decmp/meson.build index 4c7778a..6e2d7d9 100644 --- a/test/decmp/meson.build +++ b/test/decmp/meson.build @@ -1,12 +1 @@ -test_case = files('test_decmp.c') -test_runner = test_runner_generator.process(test_case) - -test_decmp = executable('test_decmp', - test_case, test_runner, - include_directories : incdir, - link_with : cmp_lib, - dependencies : unity_dep, - build_by_default : false -) - -test('Decompression Unit Tests', test_decmp) +test_cases += [[files('test_decmp.c'), 'Decompression Unit Tests']] diff --git a/test/meson.build b/test/meson.build index 63da2db..50cd3df 100644 --- a/test/meson.build +++ b/test/meson.build @@ -33,8 +33,9 @@ subdir('tools') subdir('cmp_tool') unity_dep = dependency('unity', fallback : ['unity', 'unity_dep']) - subdir('test_common') + +test_cases = [] subdir('decmp') subdir('cmp_icu') subdir('cmp_decmp') @@ -42,3 +43,31 @@ subdir('cmp_data_types') subdir('cmp_entity') subdir('cmp_rdcu_cfg') subdir('cmp_max_used_bits') + + +test_args = '-Wno-missing-declarations' # The test runner generator does not generate header files +fs = import('fs') + +foreach test : test_cases + test_src = test[0] + test_description = test[1] + + test_name = fs.name(test_src).split('.')[0] + test_runner = test_runner_generator.process(test_src) + test_libs = [cmp_lib] + + if test_name == 'test_cmp_decmp' or test_name == 'test_cmp_icu' + test_libs += test_common_lib + endif + + test_exe = executable(test_name, + test_src, test_runner, + include_directories : incdir, + link_with : test_libs, + dependencies : unity_dep, + c_args : test_args, + build_by_default : false + ) + + test(test_description, test_exe) +endforeach diff --git a/test/test_common/test_common.c b/test/test_common/test_common.c index 4f90832..7a1b25f 100644 --- a/test/test_common/test_common.c +++ b/test/test_common/test_common.c @@ -4,6 +4,7 @@ #include <string.h> #include "pcg_basic.h" +#include "test_common.h" #include <unity.h> diff --git a/test/tools/generate_test_runner.rb b/test/tools/generate_test_runner.rb index 1c0ec34..50c93f5 100755 --- a/test/tools/generate_test_runner.rb +++ b/test/tools/generate_test_runner.rb @@ -218,16 +218,16 @@ class UnityTestRunnerGenerator if @options[:defines] && !@options[:defines].empty? @options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") } end - if @options[:header_file] && !@options[:header_file].empty? - output.puts("#include \"#{File.basename(@options[:header_file])}\"") - else - @options[:includes].flatten.uniq.compact.each do |inc| - output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") - end - testfile_includes.each do |inc| - output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") - end - end + # if @options[:header_file] && !@options[:header_file].empty? + # output.puts("#include \"#{File.basename(@options[:header_file])}\"") + # else + # @options[:includes].flatten.uniq.compact.each do |inc| + # output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") + # end + # testfile_includes.each do |inc| + # output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}") + # end + # end mocks.each do |mock| output.puts("#include \"#{mock}\"") end @@ -243,13 +243,13 @@ class UnityTestRunnerGenerator def create_externs(output, tests, _mocks) output.puts("\n/*=======External Functions This Runner Calls=====*/") - output.puts("extern void #{@options[:setup_name]}(void);") - output.puts("extern void #{@options[:teardown_name]}(void);") - output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc] + # output.puts("extern void #{@options[:setup_name]}(void);") + # output.puts("extern void #{@options[:teardown_name]}(void);") + # output.puts("\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif") if @options[:externc] tests.each do |test| output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});") end - output.puts("#ifdef __cplusplus\n}\n#endif") if @options[:externc] + # output.puts("#ifdef __cplusplus\n}\n#endif") if @options[:externc] output.puts('') end @@ -324,7 +324,7 @@ class UnityTestRunnerGenerator def create_reset(output) output.puts("\n/*=======Test Reset Options=====*/") - output.puts("void #{@options[:test_reset_name]}(void);") + # output.puts("void #{@options[:test_reset_name]}(void);") output.puts("void #{@options[:test_reset_name]}(void)") output.puts('{') output.puts(" #{@options[:teardown_name]}();") @@ -333,7 +333,7 @@ class UnityTestRunnerGenerator output.puts(' CMock_Init();') output.puts(" #{@options[:setup_name]}();") output.puts('}') - output.puts("void #{@options[:test_verify_name]}(void);") + # output.puts("void #{@options[:test_verify_name]}(void);") output.puts("void #{@options[:test_verify_name]}(void)") output.puts('{') output.puts(' CMock_Verify();') @@ -342,8 +342,9 @@ class UnityTestRunnerGenerator def create_run_test(output) require 'erb' - template = ERB.new(File.read(File.join(__dir__, 'run_test.erb')), nil, '<>') - output.puts("\n" + template.result(binding)) + file = File.read(File.join(__dir__, 'run_test.erb')) + template = ERB.new(file, trim_mode: '<>') + output.puts("\n#{template.result(binding)}") end def create_args_wrappers(output, tests) -- GitLab