gem5  v21.1.0.2
Functions
coroutine.test.cc File Reference
#include <gtest/gtest.h>
#include "base/coroutine.hh"

Go to the source code of this file.

Functions

 TEST (Coroutine, Unstarted)
 This test is checking if the Coroutine, once it's created it doesn't start since the second argument of the constructor (run_coroutine) is set to false. More...
 
 TEST (Coroutine, Unfinished)
 This test is checking if the Coroutine, once it yields back to the caller, it is still marked as not finished. More...
 
 TEST (Coroutine, Passing)
 This test is checking the parameter passing interface of a coroutine which takes an integer as an argument. More...
 
 TEST (Coroutine, Returning)
 This test is checking the yielding interface of a coroutine which takes no argument and returns integers. More...
 
 TEST (Coroutine, Fibonacci)
 This test is still supposed to test the returning interface of the the Coroutine, proving how coroutine can be used for generators. More...
 
 TEST (Coroutine, Cooperative)
 This test is using a bi-channel coroutine (accepting and yielding values) for testing a cooperative task. More...
 
 TEST (Coroutine, Nested)
 This test is testing nested coroutines by using one inner and one outer coroutine. More...
 
 TEST (Coroutine, TwoCallers)
 This test is stressing the scenario where two distinct fibers are calling the same coroutine. More...
 

Function Documentation

◆ TEST() [1/8]

TEST ( Coroutine  ,
Cooperative   
)

This test is using a bi-channel coroutine (accepting and yielding values) for testing a cooperative task.

The caller and the coroutine have a string each; they are composing a new string by merging the strings together one character per time. The result string is hence passed back and forth between the coroutine and the caller.

Definition at line 185 of file coroutine.test.cc.

References gem5::ArmISA::c, expected, and gem5::Coroutine< Arg, Ret >::get().

◆ TEST() [2/8]

TEST ( Coroutine  ,
Fibonacci   
)

This test is still supposed to test the returning interface of the the Coroutine, proving how coroutine can be used for generators.

The coroutine is computing the first #steps of the fibonacci sequence and it is yielding back results one number per time.

Definition at line 144 of file coroutine.test.cc.

References expected, gem5::Coroutine< Arg, Ret >::get(), and gem5::RiscvISA::sum.

◆ TEST() [3/8]

TEST ( Coroutine  ,
Nested   
)

This test is testing nested coroutines by using one inner and one outer coroutine.

It basically ensures that yielding from the inner coroutine returns to the outer coroutine (mid-layer of execution) and not to the outer caller.

Definition at line 218 of file coroutine.test.cc.

References expected, and gem5::Coroutine< Arg, Ret >::get().

◆ TEST() [4/8]

TEST ( Coroutine  ,
Passing   
)

This test is checking the parameter passing interface of a coroutine which takes an integer as an argument.

Coroutine::operator() and CallerType::get() are the tested APIS.

Definition at line 85 of file coroutine.test.cc.

References expected, and gem5::X86ISA::val.

◆ TEST() [5/8]

TEST ( Coroutine  ,
Returning   
)

This test is checking the yielding interface of a coroutine which takes no argument and returns integers.

Coroutine::get() and CallerType::operator() are the tested APIS.

Definition at line 115 of file coroutine.test.cc.

References expected, gem5::Coroutine< Arg, Ret >::get(), and gem5::output().

◆ TEST() [6/8]

TEST ( Coroutine  ,
TwoCallers   
)

This test is stressing the scenario where two distinct fibers are calling the same coroutine.

First the test instantiates (and runs) a coroutine, then spawns another one and it passes it a reference to the first coroutine. Once the new coroutine calls the first coroutine and the first coroutine yields, we are expecting execution flow to be yielded to the second caller (the second coroutine) and not the original caller (the test itself)

Definition at line 259 of file coroutine.test.cc.

◆ TEST() [7/8]

TEST ( Coroutine  ,
Unfinished   
)

This test is checking if the Coroutine, once it yields back to the caller, it is still marked as not finished.

Definition at line 67 of file coroutine.test.cc.

◆ TEST() [8/8]

TEST ( Coroutine  ,
Unstarted   
)

This test is checking if the Coroutine, once it's created it doesn't start since the second argument of the constructor (run_coroutine) is set to false.

Definition at line 49 of file coroutine.test.cc.

References gem5::Fiber::started().


Generated on Tue Sep 21 2021 12:26:26 for gem5 by doxygen 1.8.17