fiber.test.cc (14041:ade853f97d68) fiber.test.cc (14042:7c548eb5c4c1)
1/*
1/*
2 * Copyright (c) 2019 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the

--- 10 unchanged lines hidden (view full) ---

20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
14 * Copyright 2018 Google, Inc.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are
18 * met: redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer;
20 * redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the

--- 10 unchanged lines hidden (view full) ---

32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * Authors: Gabe Black
40 * Giacomo Travaglini
28 */
29
30#include <gtest/gtest.h>
31
32#include <initializer_list>
33#include <iostream>
34#include <vector>
35
36#include "base/fiber.hh"
37
41 */
42
43#include <gtest/gtest.h>
44
45#include <initializer_list>
46#include <iostream>
47#include <vector>
48
49#include "base/fiber.hh"
50
51/** This test is checking if the "started" member has its expected
52 * value before and after the fiber runs. In the test an empty fiber
53 * is used since we are just interested on the _started member and
54 * nothing more.
55 */
56TEST(Fiber, Starting)
57{
58 class StartingFiber : public Fiber
59 {
60 public:
61 StartingFiber(Fiber *link) : Fiber(link) {}
62 void main() { /** Do nothing */ }
63 };
64
65 StartingFiber fiber(Fiber::primaryFiber());
66
67 ASSERT_FALSE(fiber.started());
68
69 fiber.run();
70
71 ASSERT_TRUE(fiber.started());
72}
73
38class SwitchingFiber : public Fiber
39{
40 public:
41 const char *name;
42 std::vector<Fiber *> next;
43
44 SwitchingFiber(const char *name, std::initializer_list<Fiber *> l);
45

--- 95 unchanged lines hidden ---
74class SwitchingFiber : public Fiber
75{
76 public:
77 const char *name;
78 std::vector<Fiber *> next;
79
80 SwitchingFiber(const char *name, std::initializer_list<Fiber *> l);
81

--- 95 unchanged lines hidden ---