Difference between revisions of "ZDTM API"
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
The test should clearly describe 3 stages: | The test should clearly describe 3 stages: | ||
− | ; Preparations | + | ;Preparations |
: These are actions that test does before the process(es) get checkpointed | : These are actions that test does before the process(es) get checkpointed | ||
Line 12: | Line 12: | ||
;Checks | ;Checks | ||
− | : After restore test should verify whether everything is OK or not | + | : After restore test should verify whether everything is OK or not and report the result |
This is achieved by using the following API calls: | This is achieved by using the following API calls: | ||
− | ;<code>test_init()</code> | + | ;<code>test_init(argc, argv)</code> |
− | :Just initializes the test subsystem. | + | :Just initializes the test subsystem. After this call the preparations stage starts. |
;<code>test_daemon()</code> | ;<code>test_daemon()</code> | ||
− | :This one says that we finished preparations and ready to get dumped at any time. | + | :This one says that we finished preparations and ready to get dumped at any time. I.e. -- the ''actions'' begin. |
+ | |||
+ | ;<code>test_go()</code> | ||
+ | :This routine checks whether the process was dumped and restored or not yet, i.e. the ''actions'' stage still goes on. | ||
;<code>test_waitsig()</code> | ;<code>test_waitsig()</code> | ||
:Calling this blocks the task till it's restored. After this the ''checks'' stage starts. | :Calling this blocks the task till it's restored. After this the ''checks'' stage starts. | ||
+ | |||
+ | ;<code>pass()</code> | ||
+ | :Calling this marks test as PASSED | ||
+ | |||
+ | ;<code>fail(message)</code> | ||
+ | :Calling this would report test failure. The ''message'' argument will be written into logs | ||
+ | |||
+ | ;<code>err(message)</code> | ||
+ | :Use this function to mark the test as being unable to work at all. | ||
+ | |||
+ | ;<code>test_msg(message)</code> | ||
+ | :This is for logging. | ||
+ | |||
From the code perspective this looks like this: | From the code perspective this looks like this: | ||
Line 32: | Line 48: | ||
test_init(argc, argv); | test_init(argc, argv); | ||
− | /* | + | /* Preparations */ |
test_daemon(); | test_daemon(); | ||
− | /* | + | #if test want to act and get c/r-ed unexpectedly |
+ | while (test_go()) { | ||
+ | /* Actions go here */ | ||
+ | } | ||
+ | #else test just want to wait for c/r to happen | ||
+ | /* Actions go here. */ | ||
test_waitsig(); | test_waitsig(); | ||
+ | #endif | ||
/* checks */ | /* checks */ |
Revision as of 16:11, 23 January 2015
This page describes the API one should use to write new test in ZDTM.
API for test itself
The test should clearly describe 3 stages:
- Preparations
- These are actions that test does before the process(es) get checkpointed
- Actions
- During this the process(es) will be interrupted at arbitrary place and get dumped
- Checks
- After restore test should verify whether everything is OK or not and report the result
This is achieved by using the following API calls:
test_init(argc, argv)
- Just initializes the test subsystem. After this call the preparations stage starts.
test_daemon()
- This one says that we finished preparations and ready to get dumped at any time. I.e. -- the actions begin.
test_go()
- This routine checks whether the process was dumped and restored or not yet, i.e. the actions stage still goes on.
test_waitsig()
- Calling this blocks the task till it's restored. After this the checks stage starts.
pass()
- Calling this marks test as PASSED
fail(message)
- Calling this would report test failure. The message argument will be written into logs
err(message)
- Use this function to mark the test as being unable to work at all.
test_msg(message)
- This is for logging.
From the code perspective this looks like this:
int main(int argc, char **argv) { test_init(argc, argv); /* Preparations */ test_daemon(); #if test want to act and get c/r-ed unexpectedly while (test_go()) { /* Actions go here */ } #else test just want to wait for c/r to happen /* Actions go here. */ test_waitsig(); #endif /* checks */ return 0; }