Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1733, Move global count into test global struct. #1737

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/cfe_testcase/src/cfe_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "cfe_assert.h"
#include "cfe_test.h"

CFE_FT_Global_t CFE_FT_Global;

/*
* Test main function
* Register this test routine with CFE Assert
Expand Down
4 changes: 4 additions & 0 deletions modules/cfe_testcase/src/cfe_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@
typedef struct
{
CFE_FS_FileWriteMetaData_t FuncTestState;
/* Generic utility counter */
int Count;
} CFE_FT_Global_t;

extern CFE_FT_Global_t CFE_FT_Global;

/**
* Name of log file to write
*
Expand Down
54 changes: 27 additions & 27 deletions modules/cfe_testcase/src/es_task_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,21 @@

#include "cfe_test.h"

uint32 count = 0;

void TaskFunction(void)
{
while (count < 200)
while (CFE_FT_Global.Count < 200)
{
count += 1;
CFE_FT_Global.Count += 1;
OS_TaskDelay(100);
}
return;
}

void TaskExitFunction(void)
{
while (count < 200)
while (CFE_FT_Global.Count < 200)
{
count += 1;
CFE_FT_Global.Count += 1;
CFE_ES_ExitChildTask();
}
return;
Expand All @@ -68,12 +66,14 @@ void TestCreateChild(void)
uint32 Flags = 0;
int ExpectedCount = 5;

CFE_FT_Global.Count = 0;

UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&TaskId, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags),
CFE_SUCCESS);
OS_TaskDelay(500);

UtAssert_True(ExpectedCount >= count - 1 && ExpectedCount <= count + 1, "countCopy (%d) == count (%d)",
(int)ExpectedCount, (int)count);
UtAssert_True(ExpectedCount >= CFE_FT_Global.Count - 1 && ExpectedCount <= CFE_FT_Global.Count + 1,
"countCopy (%d) == count (%d)", (int)ExpectedCount, (int)CFE_FT_Global.Count);

UtAssert_INT32_EQ(
CFE_ES_CreateChildTask(&TaskId2, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags),
Expand Down Expand Up @@ -130,29 +130,30 @@ void TestChildTaskDelete(void)
UtPrintf("Testing: CFE_ES_DeleteChildTask");

CFE_ES_TaskId_t TaskId;
const char * TaskName = "CHILD_TASK_1";
CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE;
size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE;
CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY;
uint32 Flags = 0;
count = 0;
int ExpectedCount = 5;
const char * TaskName = "CHILD_TASK_1";
CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE;
size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE;
CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY;
uint32 Flags = 0;
int ExpectedCount = 5;

CFE_FT_Global.Count = 0;

UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&TaskId, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags),
CFE_SUCCESS);
OS_TaskDelay(500);

UtAssert_True(ExpectedCount >= count - 1 && ExpectedCount <= count + 1, "countCopy (%d) == count (%d)",
(int)ExpectedCount, (int)count);
UtAssert_True(ExpectedCount >= CFE_FT_Global.Count - 1 && ExpectedCount <= CFE_FT_Global.Count + 1,
"countCopy (%d) == count (%d)", (int)ExpectedCount, (int)CFE_FT_Global.Count);

ExpectedCount = count;
ExpectedCount = CFE_FT_Global.Count;

UtAssert_INT32_EQ(CFE_ES_DeleteChildTask(TaskId), CFE_SUCCESS);

OS_TaskDelay(500);

UtAssert_True(ExpectedCount == count || ExpectedCount == count + 1, "ExpectedCount (%d) == count (%d)",
(int)ExpectedCount, (int)count);
UtAssert_True(ExpectedCount == CFE_FT_Global.Count || ExpectedCount == CFE_FT_Global.Count + 1,
"ExpectedCount (%d) == count (%d)", (int)ExpectedCount, (int)CFE_FT_Global.Count);

UtAssert_INT32_EQ(CFE_ES_DeleteChildTask(CFE_ES_TASKID_UNDEFINED), CFE_ES_ERR_RESOURCEID_NOT_VALID);
}
Expand All @@ -162,13 +163,12 @@ void TestExitChild(void)
UtPrintf("Testing: CFE_ES_ExitChildTask");

CFE_ES_TaskId_t TaskId;
const char * TaskName = "CHILD_TASK_1";
CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE;
size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE;
CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY;
uint32 Flags = 0;
count = 0;
int ExpectedCount = 1;
const char * TaskName = "CHILD_TASK_1";
CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE;
size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE;
CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY;
uint32 Flags = 0;
int ExpectedCount = 1;

UtAssert_INT32_EQ(
CFE_ES_CreateChildTask(&TaskId, TaskName, TaskExitFunction, StackPointer, StackSize, Priority, Flags),
Expand Down
3 changes: 0 additions & 3 deletions modules/cfe_testcase/src/fs_util_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

#include "cfe_test.h"

CFE_FT_Global_t CFE_FT_Global;

void TestFileCategory(void)
{
UtPrintf("Testing: CFE_FS_GetDefaultMountPoint, CFE_FS_GetDefaultExtension");
Expand Down Expand Up @@ -138,7 +136,6 @@ void TestFileDump(void)

UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), false);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(&CFE_FT_Global.FuncTestState), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), true);

/* Wait for background task to complete */
while (CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState) && count < MaxWait)
Expand Down