Skip to content
Snippets Groups Projects
Commit ce1970da authored by Florian Fischer's avatar Florian Fischer
Browse files

[test] remove feature_flags from test and introduce io test runner

To skip test if emper::IO is false the new io test runner in
tests/test-runner is introduced which checks emper::IO and skips the
test otherwise executes our normal testMain function.

Fixes #10.
parent bd5d0d3d
No related branches found
No related tags found
1 merge request!1WIP: Emper shutdown
......@@ -6,6 +6,7 @@
#include <vector>
#include "CountingPrivateSemaphore.hpp"
#include "Emper.hpp"
#include "Fiber.hpp"
#include "Runtime.hpp"
#include "emper.hpp"
......@@ -16,6 +17,10 @@
#define BUF_SIZE 1024
auto main(int argc, char* argv[]) -> int {
if constexpr (!emper::IO) {
exit(77);
}
unsigned int client_count = 10;
unsigned int echos = 1000;
int port = PORT;
......
test_fixtures_include_dir = include_directories('.')
test_fixtures_sources = []
if get_option('io')
test_fixtures_sources += ['network.cpp']
endif
test_fixtures_sources = ['network.cpp']
test_fixtures_lib = library(
'test-fixtures',
......
......@@ -32,7 +32,7 @@ tests = {
'ReuseBpsTest.cpp':
{
'description': 'Test resetting of BPSs',
'emper_test_runner': true,
'test_runner': 'emper',
},
'SimpleActorTest.cpp':
......@@ -64,92 +64,82 @@ tests = {
'description': 'Simple test for PrivateSemaphore:signalFromAnywhere()',
'test_suite': 'smoke',
# 'is_parallel': true,
'emper_test_runner': true,
'test_runner': 'emper',
},
'TellActorFromAnywhereTest.cpp':
{
'description': 'Simple test for Actor:tellFromAnywhere()',
'test_suite': 'smoke',
# 'is_parallel': true,
'emper_test_runner': true,
'test_runner': 'emper',
},
'IncrementalCompletionTest.cpp':
{
'feature_flags': ['io'],
'description': 'Test incremental completion for hugre reads/writes',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'ReuseFutureTest.cpp':
{
'feature_flags': ['io'],
'description': 'Test reusing Future objects',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'LinkFutureTest.cpp':
{
'feature_flags': ['io'],
'description': 'Test linking Future objects',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'TooLongFutureChain.cpp':
{
'feature_flags': ['io'],
'description': 'Test linking Future objects',
'test_suite': 'io',
'should_fail': true,
'emper_test_runner': true,
'test_runner': 'io',
},
'AlarmFutureTest.cpp':
{
'feature_flags': ['io'],
'description': 'Test AlarmFuture object based timeouts',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'TimeoutWrapperTest.cpp':
{
'feature_flags': ['io'],
'description': 'Test TimeoutWrapper object based IO request timeouts',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'CancelFutureTest.cpp':
{
'feature_flags': ['io'],
'description': 'Test Future cancellation',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'SimpleNetworkTest.cpp':
{
'feature_flags': ['io'],
'description': 'Simple network test',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'SimpleDiskAndNetworkTest.cpp':
{
'feature_flags': ['io'],
'description': 'Simple network and disk IO test',
'test_suite': 'io',
'emper_test_runner': true,
'test_runner': 'io',
},
'ConcurrentNetworkEchoTest.cpp':
{
'feature_flags': ['io'],
'description': 'Concurrent network echo test with 10 clients',
'test_suite': 'io',
'args': ['10', '10000'],
......@@ -170,20 +160,6 @@ test_env = environment(
subdir('test-runner')
foreach source, test_dict : tests
# check feature flags
if test_dict.has_key('feature_flags')
include_test = true
foreach flag : test_dict.get('feature_flags')
if not get_option(flag)
include_test = false
break
endif
endforeach
if not include_test
continue
endif
endif
# TODO: Use meson fs (filesystem) module once meson >= 0.53 is in
# buster-backports, instead of split('.')[0]
# test_name = fs.replace_suffix(source, '')
......@@ -195,8 +171,8 @@ foreach source, test_dict : tests
test_deps += test_dict['dependencies']
endif
if test_dict.get('emper_test_runner', false)
test_deps += emper_test_runner_dep
if test_dict.has_key('test_runner')
test_deps += test_runners[test_dict['test_runner']]
endif
test_exe = executable(test_name,
......
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Schmaus
#include <cstdlib>
#include <iostream>
#include "Fiber.hpp"
#include "Runtime.hpp"
#include "emper-common.h"
#include "test-runner.hpp"
void emperTest() __attribute__((weak));
static void invokeTest() {
emperTest();
exit(EXIT_SUCCESS);
}
auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int {
if (!&emperTest) {
std::cerr << "ERROR: The emperTest() method is not defined.";
return EXIT_FAILURE;
}
Runtime runtime;
Fiber* alphaFiber = Fiber::from(&invokeTest);
runtime.scheduleFromAnywhere(*alphaFiber);
runtime.waitUntilFinished();
return EXIT_FAILURE;
}
auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int { return testMain(); }
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020-2021 Florian Schmaus, Florian Fischer
#include <cstdlib>
#include "Emper.hpp"
#include "emper-common.h"
#include "test-runner.hpp"
auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int {
if constexpr (!emper::IO) {
exit(77);
}
return testMain();
}
emper_test_runner_lib = library('emper-test-runner',
'emper-test-runner.cpp',
dependencies: emper_dep
)
test_runners = {}
emper_test_runner_dep = declare_dependency(
link_with : emper_test_runner_lib
)
avail_test_runners = {
'emper': {
'sources': ['emper-test-runner.cpp'],
},
'io': {
'sources': ['io-test-runner.cpp'],
},
}
foreach runner, runner_dict : avail_test_runners
runner_lib = library(runner + '-test-runner',
['test-runner.cpp'] + runner_dict['sources'],
dependencies: [emper_dep] + runner_dict.get('deps', []))
test_runners += {runner: declare_dependency(link_with: runner_lib)}
endforeach
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020-2021 Florian Schmaus, Florian Fischer
#include "test-runner.hpp"
#include <cstdlib>
#include <iostream>
#include "Fiber.hpp"
#include "Runtime.hpp"
void invokeTest() {
emperTest();
exit(EXIT_SUCCESS);
}
auto testMain() -> int {
if (!&emperTest) {
std::cerr << "ERROR: The emperTest() method is not defined.";
return EXIT_FAILURE;
}
Runtime runtime;
Fiber* alphaFiber = Fiber::from(&invokeTest);
runtime.scheduleFromAnywhere(*alphaFiber);
runtime.waitUntilFinished();
return EXIT_FAILURE;
}
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020-2021 Florian Schmaus, Florian Fischer
#pragma once
void emperTest() __attribute__((weak));
void invokeTest();
auto testMain() -> int;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment