FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Unit tests for the fossscheduler library section of libfossology. More...
#include <libfossscheduler.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <libfocunit.h>
Go to the source code of this file.
Macros | |
#define | COMMIT_HASH "COMMIT_HASH Unknown" |
#define | FROM_UNIT "UNIT\n" |
#define | VERBOSE_TEST 7 |
#define | NC_TEST "Not a Command\n" |
#define | write_con(...) |
Functions | |
void | fo_heartbeat () |
Internal function to send a heartbeat to the scheduler along with the number of items processed. More... | |
void | set_up (void) |
Since the fossscheduler library depends on reading and writing very specific data to stdin and stdout, these both need to be replaced with pipes. The set_up function pretends to be a test so that it can do this before any other test gets run. More... | |
void | tear_down (void) |
This function closes the pipes created in the setup function and returns stdin and stdout to their original values. This essentially is the inverse of the set_up() function. More... | |
void | signal_connect_end () |
Test for fo_scheduler_next() blocking. More... | |
void | signal_connect_verbose () |
Serves the same purpose for the verbose command as the signal_connect_end() function does for the end command. More... | |
void | signal_connect_version () |
Test for version string. More... | |
void | test_scheduler_no_connect () |
Test for fo_scheduler_connect() with no new connection. More... | |
void | test_scheduler_connect () |
Test for fo_scheduler_connect() with a new connection. More... | |
void | test_scheduler_next_close () |
Tests sending "CLOSE\n" to stdin for the scheduler next function. More... | |
void | test_scheduler_next_end () |
Tests sending "END\n" to the stdin for the scheduler next function. More... | |
void | test_scheduler_next_verbose () |
Tests sending "VERBOSE #\n" to the stdin for the scheduler next function. More... | |
void | test_scheduler_next_version () |
Tests sending "VERSION\n" to the stdin for the scheduler next function. More... | |
void | test_scheduler_next_oth () |
Tests scheduler for non commands. More... | |
void | test_scheduler_current () |
Tests the scheduler current function. More... | |
void | test_scheduler_disconnect () |
Tests the scheduler disconnection function. More... | |
void | test_scheduler_heart () |
Test the scheduler heart function. This function must set up the heartbeat again so that it can check that the heartbeat will increase correctly. More... | |
Variables | |
int | items_processed |
The number of items processed by the agent. | |
int | valid |
If the information stored in buffer is valid. | |
int | sscheduler |
Whether the agent was started by the scheduler. | |
int | agent_verbose |
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level for a particular agent. All agents should use this flag for verbose instead of one declared within the agent. This can be set by the scheduler to enable different levels of verbose. More... | |
char | tbuffer [1024] |
int | in_sub [2] |
int | out_sub [2] |
int | stdin_t |
int | stdout_t |
FILE * | read_from |
FILE * | write_to |
CU_TestInfo | fossscheduler_testcases [] |
Unit tests for the fossscheduler library section of libfossology.
Definition in file test_fossscheduler.c.
#define write_con | ( | ... | ) |
Definition at line 53 of file test_fossscheduler.c.
void fo_heartbeat | ( | ) |
Internal function to send a heartbeat to the scheduler along with the number of items processed.
Definition at line 75 of file libfossscheduler.c.
void set_up | ( | void | ) |
Since the fossscheduler library depends on reading and writing very specific data to stdin and stdout, these both need to be replaced with pipes. The set_up function pretends to be a test so that it can do this before any other test gets run.
Definition at line 65 of file test_fossscheduler.c.
void signal_connect_end | ( | ) |
Test for fo_scheduler_next() blocking.
"CLOSE\n"
or a non-command message is sent a signal is needed to test the intermediate state of the connection. This will check that the "END\n"
command left the connection in the correct state and then send a "CLOSE\n"
command so that fo_scheduler_next() will return in the main thread. Definition at line 112 of file test_fossscheduler.c.
void signal_connect_verbose | ( | ) |
Serves the same purpose for the verbose command as the signal_connect_end() function does for the end command.
Definition at line 129 of file test_fossscheduler.c.
void signal_connect_version | ( | ) |
Test for version string.
Definition at line 145 of file test_fossscheduler.c.
void tear_down | ( | void | ) |
This function closes the pipes created in the setup function and returns stdin and stdout to their original values. This essentially is the inverse of the set_up() function.
Definition at line 88 of file test_fossscheduler.c.
void test_scheduler_connect | ( | ) |
Test for fo_scheduler_connect() with a new connection.
--scheduler_start
as a command line arg to fo_scheduler_connect(). The alarm, sleep and following assert check that the heart beat was correctly created. Definition at line 199 of file test_fossscheduler.c.
void test_scheduler_current | ( | ) |
Tests the scheduler current function.
CLOSE\n
to the schedulerDefinition at line 335 of file test_fossscheduler.c.
void test_scheduler_disconnect | ( | ) |
Tests the scheduler disconnection function.
BYE #\n
Definition at line 352 of file test_fossscheduler.c.
void test_scheduler_heart | ( | ) |
Test the scheduler heart function. This function must set up the heartbeat again so that it can check that the heartbeat will increase correctly.
SIGALRM
and check if scheduler returns HEART: 11
. Definition at line 373 of file test_fossscheduler.c.
void test_scheduler_next_close | ( | ) |
Tests sending "CLOSE\n"
to stdin for the scheduler next function.
CLOSE\n
to the schedulerDefinition at line 238 of file test_fossscheduler.c.
void test_scheduler_next_end | ( | ) |
Tests sending "END\n"
to the stdin for the scheduler next function.
END\n
to the schedulerSIGALRM
Definition at line 255 of file test_fossscheduler.c.
void test_scheduler_next_oth | ( | ) |
Tests scheduler for non commands.
Definition at line 317 of file test_fossscheduler.c.
void test_scheduler_next_verbose | ( | ) |
Tests sending "VERBOSE #\n"
to the stdin for the scheduler next function.
VERBOSE #\n
to the schedulerSIGALRM
Definition at line 276 of file test_fossscheduler.c.
void test_scheduler_next_version | ( | ) |
Tests sending "VERSION\n"
to the stdin for the scheduler next function.
VERSION\n
to the schedulerSIGALRM
Definition at line 297 of file test_fossscheduler.c.
void test_scheduler_no_connect | ( | ) |
Test for fo_scheduler_connect() with no new connection.
--scheduler_start
as a command line arg to fo_scheduler_connect() Definition at line 167 of file test_fossscheduler.c.
|
extern |
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level for a particular agent. All agents should use this flag for verbose instead of one declared within the agent. This can be set by the scheduler to enable different levels of verbose.
Global verbose flags that agents should use instead of specific verbose flags. This is used by the scheduler to turn verbose on a particular agent on during run time. When the verbose flag is turned on by the scheduler the on_verbose function will be called. If nothing needs to be done when verbose is turned on, simply pass NULL to scheduler_connect
Definition at line 64 of file libfossscheduler.c.
CU_TestInfo fossscheduler_testcases[] |
Definition at line 394 of file test_fossscheduler.c.