Flutter Engine
The Flutter Engine
unit_test.h
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5// A slimmed down version of runtime/vm/unit_test.h that only runs C++
6// non-DartVM unit tests.
7
8#ifndef RUNTIME_VM_COMPILER_FFI_UNIT_TEST_H_
9#define RUNTIME_VM_COMPILER_FFI_UNIT_TEST_H_
10
11// Don't use the DartVM zone, so include this first.
13
14#include "platform/globals.h"
15
16// The UNIT_TEST_CASE macro is used for tests.
17#define UNIT_TEST_CASE_WITH_EXPECTATION(name, expectation) \
18 void Dart_Test##name(); \
19 static const dart::compiler::ffi::RawTestCase kRegister##name( \
20 Dart_Test##name, #name, expectation); \
21 void Dart_Test##name()
22
23#define UNIT_TEST_CASE(name) UNIT_TEST_CASE_WITH_EXPECTATION(name, "Pass")
24
25// The UNIT_TEST_CASE_WITH_ZONE macro is used for tests that need a custom
26// dart::Zone.
27#define UNIT_TEST_CASE_WITH_ZONE_WITH_EXPECTATION(name, expectation) \
28 static void Dart_TestHelper##name(dart::Zone* Z); \
29 UNIT_TEST_CASE_WITH_EXPECTATION(name, expectation) { \
30 dart::Zone zone; \
31 Dart_TestHelper##name(&zone); \
32 } \
33 static void Dart_TestHelper##name(dart::Zone* Z)
34
35#define UNIT_TEST_CASE_WITH_ZONE(name) \
36 UNIT_TEST_CASE_WITH_ZONE_WITH_EXPECTATION(name, "Pass")
37
38namespace dart {
39namespace compiler {
40namespace ffi {
41
42extern const char* kArch;
43extern const char* kOs;
44
45void WriteToFile(char* path, const char* contents);
46
47void ReadFromFile(char* path, char** buffer_pointer);
48
50 public:
51 explicit TestCaseBase(const char* name, const char* expectation);
52 virtual ~TestCaseBase() {}
53
54 const char* name() const { return name_; }
55 const char* expectation() const { return expectation_; }
56
57 virtual void Run() = 0;
58 void RunTest();
59
60 static void RunAll();
61 static void RunAllRaw();
62
64
65 private:
66 static TestCaseBase* first_;
67 static TestCaseBase* tail_;
68
69 TestCaseBase* next_;
70 const char* name_;
71 const char* expectation_;
72
73 DISALLOW_COPY_AND_ASSIGN(TestCaseBase);
74};
75
77 public:
78 typedef void(RunEntry)();
79
80 RawTestCase(RunEntry* run, const char* name, const char* expectation)
81 : TestCaseBase(name, expectation), run_(run) {}
82 virtual void Run();
83
84 private:
85 RunEntry* const run_;
86};
87
88} // namespace ffi
89} // namespace compiler
90} // namespace dart
91
92#endif // RUNTIME_VM_COMPILER_FFI_UNIT_TEST_H_
RawTestCase(RunEntry *run, const char *name, const char *expectation)
Definition: unit_test.h:80
const char * name() const
Definition: unit_test.h:54
TestCaseBase(const char *name, const char *expectation)
const char * expectation() const
Definition: unit_test.h:55
void WriteToFile(char *path, const char *contents)
Definition: unit_test.cc:20
const char * kArch
void ReadFromFile(char *path, char **buffer_pointer)
Definition: unit_test.cc:31
const char * kOs
Definition: unit_test.cc:17
Definition: dart_vm.cc:33
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
Definition: run.py:1