Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
seastar_test.hh
1/*
2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
6 *
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18
19/*
20 * Copyright (C) 2014 Cloudius Systems, Ltd.
21 */
22
23#pragma once
24
25#include <exception>
26#include <string_view>
27#include <boost/test/unit_test.hpp> // IWYU pragma: export
28#include <seastar/core/future.hh>
29#include <seastar/testing/entry_point.hh> // IWYU pragma: keep
30
31#define SEASTAR_TEST_INVOKE(func, ...) func(__VA_ARGS__)
32
33namespace seastar {
34
35namespace testing {
36
38 const std::string _test_file;
39public:
40 seastar_test(const char* test_name, const char* test_file, int test_line);
41 seastar_test(const char* test_name, const char* test_file, int test_line,
42 boost::unit_test::decorator::collector_t& decorators);
43 virtual ~seastar_test() {}
44 const std::string& get_test_file() const {
45 return _test_file;
46 }
47 static const std::string& get_name();
48 virtual future<> run_test_case() const = 0;
49 void run();
50};
51
52// BOOST_REQUIRE_EXCEPTION predicates
53namespace exception_predicate {
54
55std::function<bool(const std::exception&)> message_equals(std::string_view expected_message);
56std::function<bool(const std::exception&)> message_contains(std::string_view expected_message);
57
58} // exception_predicate
59
60}
61
62}
63
64#ifdef SEASTAR_TESTING_MAIN
65
66int main(int argc, char** argv) {
67 return seastar::testing::entry_point(argc, argv);
68}
69
70#endif // SEASTAR_TESTING_MAIN
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Definition: seastar_test.hh:37
Seastar API namespace.
Definition: abort_on_ebadf.hh:26