Motr  M0
sm.c File Reference
#include "ut/ut.h"
#include "lib/ub.h"
#include "lib/time.h"
#include "lib/errno.h"
#include "lib/arith.h"
#include "lib/misc.h"
#include "lib/thread.h"
#include "sm/sm.h"
Include dependency graph for sm.c:

Go to the source code of this file.

Data Structures

struct  story
 

Enumerations

enum  {
  C_INIT, C_FLIP, C_HEAD, C_TAIL,
  C_DONE, C_OVER, C_WIN, C_LOSE,
  C_TIE, C_NR
}
 
enum  {
  S_TMO_INITIAL, S_TMO_0, S_TMO_1, S_TMO_2,
  S_TMO_TERMINAL, S_TMO_NR
}
 
enum  {
  S_INITIAL, S_ITERATE, S_FRATRICIDE, S_TERMINAL,
  S_NR
}
 
enum  { NR_RUNS = 20 }
 

Functions

static void ast_thread (int __d)
 
static int init (void)
 
static int fini (void)
 
static void transition (void)
 
static void ast_cb (struct m0_sm_group *g, struct m0_sm_ast *a)
 
static void ast_test (void)
 
static void timeout (void)
 
static int genesis_4_8 (struct m0_sm *mach)
 
static void group (void)
 
static int flip (struct m0_sm *mach)
 
static int head (struct m0_sm *mach)
 
static int tail (struct m0_sm *mach)
 
static int over (struct m0_sm *mach)
 
static void chain (void)
 
static void ast_wait_cb (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static void ast_wait (void)
 

Variables

static struct m0_sm_group G
 
static struct m0_sm m
 
static struct m0_sm_ast ast
 
static bool more
 
static struct m0_thread ath
 
static int heads
 
static int tails
 
static bool x
 
static struct m0_sm_state_descr tmo_states [S_TMO_NR]
 
static const struct m0_sm_conf tmo_sm_conf
 
static struct m0_sm_state_descr states [C_NR]
 
static const struct m0_sm_conf conf
 
static struct m0_sm_ast_wait wait
 
static struct m0_mutex wait_guard
 
struct m0_ut_suite sm_ut
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
C_INIT 
C_FLIP 
C_HEAD 
C_TAIL 
C_DONE 
C_OVER 
C_WIN 
C_LOSE 
C_TIE 
C_NR 

Definition at line 39 of file sm.c.

◆ anonymous enum

anonymous enum

Unit test for m0_sm_timeout_arm().

dot_inline_dotgraph_1.png
Enumerator
S_TMO_INITIAL 
S_TMO_0 
S_TMO_1 
S_TMO_2 
S_TMO_TERMINAL 
S_TMO_NR 

Definition at line 235 of file sm.c.

◆ anonymous enum

anonymous enum
Enumerator
S_INITIAL 
S_ITERATE 
S_FRATRICIDE 
S_TERMINAL 
S_NR 

Definition at line 362 of file sm.c.

◆ anonymous enum

anonymous enum
Enumerator
NR_RUNS 

Definition at line 587 of file sm.c.

Function Documentation

◆ ast_cb()

static void ast_cb ( struct m0_sm_group g,
struct m0_sm_ast a 
)
static

Definition at line 170 of file sm.c.

Here is the caller graph for this function:

◆ ast_test()

static void ast_test ( void  )
static

Unit test for m0_sm_ast_post().

Definition at line 181 of file sm.c.

Here is the call graph for this function:

◆ ast_thread()

static void ast_thread ( int  __d)
static

Definition at line 46 of file sm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ast_wait()

static void ast_wait ( void  )
static

Definition at line 627 of file sm.c.

Here is the call graph for this function:

◆ ast_wait_cb()

static void ast_wait_cb ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 619 of file sm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chain()

static void chain ( void  )
static

Definition at line 595 of file sm.c.

Here is the call graph for this function:

◆ fini()

static int fini ( void  )
static

Definition at line 68 of file sm.c.

Here is the call graph for this function:

◆ flip()

static int flip ( struct m0_sm mach)
static

Definition at line 461 of file sm.c.

Here is the call graph for this function:

◆ genesis_4_8()

static int genesis_4_8 ( struct m0_sm mach)
static

Definition at line 364 of file sm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ group()

static void group ( void  )
static

Unit test for multiple machines in the group.

dot_inline_dotgraph_2.png

Definition at line 386 of file sm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ head()

static int head ( struct m0_sm mach)
static

Definition at line 468 of file sm.c.

Here is the caller graph for this function:

◆ init()

static int init ( void  )
static

Definition at line 56 of file sm.c.

Here is the call graph for this function:

◆ over()

static int over ( struct m0_sm mach)
static

Definition at line 480 of file sm.c.

◆ tail()

static int tail ( struct m0_sm mach)
static

Definition at line 474 of file sm.c.

Here is the caller graph for this function:

◆ timeout()

static void timeout ( void  )
static

Definition at line 286 of file sm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transition()

static void transition ( void  )
static

Unit test for m0_sm_state_set().

Performs a state transition for a very simple state machine:

dot_inline_dotgraph_3.png

Definition at line 88 of file sm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ast

struct m0_sm_ast ast
static

Definition at line 35 of file sm.c.

◆ ath

struct m0_thread ath
static

Definition at line 37 of file sm.c.

◆ conf

const struct m0_sm_conf conf
static
Initial value:
= {
.scf_name = "test drive: chain",
.scf_nr_states = C_NR,
.scf_state = states
}
Definition: sm.c:40
static struct m0_sm_state_descr states[C_NR]
Definition: sm.c:512

Definition at line 589 of file sm.c.

◆ G

struct m0_sm_group G
static

Definition at line 33 of file sm.c.

◆ heads

int heads
static

Definition at line 42 of file sm.c.

◆ m

struct m0_sm m
static

Definition at line 34 of file sm.c.

◆ more

bool more
static

Definition at line 36 of file sm.c.

◆ sm_ut

struct m0_ut_suite sm_ut
Initial value:
= {
.ts_name = "sm-ut",
.ts_init = init,
.ts_fini = fini,
.ts_tests = {
{ "transition", transition },
{ "ast", ast_test },
{ "timeout", timeout },
{ "group", group },
{ "chain", chain },
{ "wait", ast_wait },
{ NULL, NULL }
}
}
static void transition(void)
Definition: sm.c:88
#define NULL
Definition: misc.h:38
static void timeout(void)
Definition: sm.c:286
static void ast_test(void)
Definition: sm.c:181
static int init(void)
Definition: sm.c:56
static void group(void)
Definition: sm.c:386
static void ast_wait(void)
Definition: sm.c:627
static void chain(void)
Definition: sm.c:595
static int fini(void)
Definition: sm.c:68

Definition at line 643 of file sm.c.

◆ states

struct m0_sm_state_descr states[C_NR]
static

Unit test for chained state transition incurred by ->sd_in() call-back.

dot_inline_dotgraph_4.png

Definition at line 512 of file sm.c.

◆ tails

int tails
static

Definition at line 43 of file sm.c.

◆ tmo_sm_conf

const struct m0_sm_conf tmo_sm_conf
static
Initial value:
= {
.scf_name = "test drive: timeout",
.scf_nr_states = S_TMO_NR,
.scf_state = tmo_states
}
static struct m0_sm_state_descr tmo_states[S_TMO_NR]
Definition: sm.c:237
Definition: sm.c:235

Definition at line 280 of file sm.c.

◆ tmo_states

struct m0_sm_state_descr tmo_states[S_TMO_NR]
static

Definition at line 237 of file sm.c.

◆ wait

struct m0_sm_ast_wait wait
static

Definition at line 616 of file sm.c.

◆ wait_guard

struct m0_mutex wait_guard
static

Definition at line 617 of file sm.c.

◆ x

bool x
static

Definition at line 168 of file sm.c.