FOSSology  4.7.1
Open Source License Compliance by Open Source Software
test_walk_tree.c File Reference

Nested-set parity and per-node heartbeat regression tests. More...

#include <libfossology.h>
#include <libfocunit.h>
#include <sys/resource.h>
#include "../../agent/adj2nest.c"
Include dependency graph for test_walk_tree.c:

Go to the source code of this file.

Classes

struct  nested_set
 

Macros

#define main   adj2nest_main
 
#define PQexec   capture_update
 
#define PQclear   capture_clear
 
#define fo_scheduler_heart   capture_heart
 

Functions

static PGresult * capture_update (PGconn *connection, const char *query)
 
static void capture_clear (PGresult *result)
 
static void capture_heart (int items)
 
static void set_up (void)
 
static void tear_down (void)
 
static void make_tree (long count)
 
static int compare_pk (const void *a, const void *b)
 
static const nested_set * find_row (long index)
 
static void assert_range (long index, long lft, long rgt)
 
static void run_walk (void)
 
static void walk_recursive (long index, long *number)
 
static void assert_recursive_parity (void)
 
static void test_single_node (void)
 
static void test_siblings (void)
 
static void test_mixed_tree (void)
 
static void test_deep_tree (void)
 
static void test_generated_tree (void)
 
static void test_wide_tree (void)
 
int main (int argc, char **argv)
 

Variables

volatile gint items_processed
 The number of items processed by the agent.
 
volatile int alive
 If the agent has updated with a hearbeat.
 
static nested_set * actual
 
static nested_set * expected
 
static unsigned char * endpoints
 
static PGresult * command_result
 
static long update_count
 
static long clear_count
 
static long heart_count
 
static long expected_count
 
static struct rlimit saved_stack_limit
 
static int stack_limited
 
static CU_TestInfo walk_tree_tests []
 
static CU_SuiteInfo suites []
 

Detailed Description

Nested-set parity and per-node heartbeat regression tests.

Exercise the production traversal without a database or scheduler process. Database updates are captured as (uploadtree_pk, lft, rgt) tuples; heartbeat calls are checked and forwarded to the real scheduler library. This tests progress/aliveness updates, not wall-clock heartbeat delivery or DB latency.

Definition in file test_walk_tree.c.

Function Documentation

◆ walk_recursive()

static void walk_recursive ( long  index,
long *  number 
)
static

Frozen numbering logic from WalkTree before commit 1766d5b1c17. Both children and siblings recurse. Keep independent of the production SetNum and DB mocks; never use this oracle on the stack-overflow fixture.

Definition at line 221 of file test_walk_tree.c.

Variable Documentation

◆ suites

CU_SuiteInfo suites[]
static
Initial value:
= {
{"WalkTree", NULL, NULL, set_up, tear_down, walk_tree_tests},
CU_SUITE_INFO_NULL
}
void set_up(void)
Since the fossscheduler library depends on reading and writing very specific data to stdin and stdout...
void tear_down(void)
This function closes the pipes created in the setup function and returns stdin and stdout to their or...

Definition at line 369 of file test_walk_tree.c.

◆ walk_tree_tests

CU_TestInfo walk_tree_tests[]
static
Initial value:
= {
{"single node", test_single_node},
{"siblings", test_siblings},
{"mixed tree", test_mixed_tree},
{"deep tree", test_deep_tree},
{"generated tree", test_generated_tree},
{"100000 siblings with bounded stack", test_wide_tree},
CU_TEST_INFO_NULL
}

Definition at line 359 of file test_walk_tree.c.