Skip to content
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: 1 addition & 1 deletion .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: L1 Unit Tests

on:
pull_request:
branches: [ develop ]
branches: [ develop, support/1.8 ]

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/L2-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: L2 Integration Tests

on:
pull_request:
branches: [ develop ]
branches: [ develop, support/1.8 ]

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
Expand Down
20 changes: 20 additions & 0 deletions source/dcautil/dca.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ int processTopPattern(char* profileName, Vector* topMarkerList, int profileExec
{
continue;
}
if (topMarkerObj->cpuValue)
{
free(topMarkerObj->cpuValue);
topMarkerObj->cpuValue = NULL;
}
if (topMarkerObj->memValue)
{
free(topMarkerObj->memValue);
topMarkerObj->memValue = NULL;
}
Comment thread
yogeswaransky marked this conversation as resolved.
Comment thread
yogeswaransky marked this conversation as resolved.
int tmp_skip_interval, is_skip_param;
tmp_skip_interval = topMarkerObj->skipFreq;
if(tmp_skip_interval <= 0)
Expand Down Expand Up @@ -309,6 +319,16 @@ int processTopPattern(char* profileName, Vector* topMarkerList, int profileExec
continue;
}

if (topMarkerObj->cpuValue)
{
free(topMarkerObj->cpuValue);
topMarkerObj->cpuValue = NULL;
}
if (topMarkerObj->memValue)
{
free(topMarkerObj->memValue);
topMarkerObj->memValue = NULL;
}

// If the skip frequency is set, skip the marker processing for this interval
int tmp_skip_interval, is_skip_param;
Expand Down
18 changes: 6 additions & 12 deletions source/dcautil/dcaproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,6 @@ int getProcUsage(char *processName, TopMarker* marker, char* filename)

pInfo.total_instance = index;
pInfo.pid = pid;
if (marker->cpuValue)
{
free(marker->cpuValue);
marker->cpuValue = NULL;
}
if (marker->memValue)
{
free(marker->memValue);
marker->memValue = NULL;
}
if(0 != getProcInfo(&pInfo, filename))
{
T2Debug("Process info - CPU: %s, Memory: %s \n", pInfo.cpuUse, pInfo.memUse);
Expand Down Expand Up @@ -599,8 +589,10 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename)
if(strcasestr(top_op, pInfo->processName) == NULL)
{
int line_pid = 0;
if(sscanf(top_op, "%d", &line_pid) != 1 || line_pid != pInfo->pid[0])
if(pInfo->pid == NULL || sscanf(top_op, "%d", &line_pid) != 1 || line_pid != pInfo->pid[0])
{
continue;
}
}
if(sscanf(top_op, "%s %s %s %s %s %s %s %s", var1, var2, var3, var4, var5, var6, var7, var8) == 8)
{
Expand All @@ -616,8 +608,10 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename)
if(strcasestr(top_op, pInfo->processName) == NULL)
{
int line_pid = 0;
if(sscanf(top_op, "%d", &line_pid) != 1 || line_pid != pInfo->pid[0])
if(pInfo->pid == NULL || sscanf(top_op, "%d", &line_pid) != 1 || line_pid != pInfo->pid[0])
{
continue;
}
}
if(sscanf(top_op, "%16s %16s %16s %16s %16s %16s %16s %512s %512s %512s", var1, var2, var3, var4, var5, var6, var7, var8, var9, var10) == 10)
{
Expand Down
2 changes: 1 addition & 1 deletion source/dcautil/dcautil.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void freeGResult(void *data);
T2ERROR saveGrepConfig(char *name, Vector* grepMarkerList);
T2ERROR getGrepResults(GrepSeekProfile **GSP, Vector *markerList, bool isClearSeekMap, bool check_rotated, char *customLogPath);
#define PREFIX_SIZE 5
#define BUF_LEN 16
#define BUF_LEN 64

typedef struct proc_info
{
Expand Down
25 changes: 15 additions & 10 deletions source/test/dcautils/dcautilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ TEST(GETPROCINFO, PMINFO_NULL)
memset(&pInfo, '\0', sizeof(procMemCpuInfo));
memcpy(pInfo.processName, processName, strlen(processName) + 1);
pInfo.total_instance = 0;
EXPECT_EQ(0,getProcInfo(&pInfo, NULL));
EXPECT_NE(0,getProcInfo(&pInfo, NULL));
free(filename);
}

Expand Down Expand Up @@ -1104,33 +1104,38 @@ TEST_F(dcaTestFixture, processTopPattern2)
.WillOnce(Return(0));
#endif
FILE* fp = (FILE*)0xFFFFFFFF;
//getProcUsage
//getProcUsage - pidof
#ifdef LIBSYSWRAPPER_BUILD
EXPECT_CALL(*g_fileIOMock, v_secure_popen(_,_))
.Times(3)
.WillOnce(Return(fp))
.Times(2)
.WillOnce(Return(fp))
.WillOnce(Return(fp));
#else
EXPECT_CALL(*g_fileIOMock, popen(_,_))
.Times(2)
.WillOnce(Return(fp))
.Times(1)
.WillOnce(Return(fp));
#endif

#ifdef LIBSYSWRAPPER_BUILD
EXPECT_CALL(*g_fileIOMock, v_secure_pclose(_))
.Times(3)
.WillOnce(Return(0))
.Times(2)
.WillOnce(Return(0))
.WillOnce(Return(0));
#else
EXPECT_CALL(*g_fileIOMock, pclose(_))
.Times(2)
.WillOnce(Return(0))
.Times(1)
.WillOnce(Return(0));
#endif

// getCPUInfo reads TOPTEMP file directly via fopen
FILE* topfp = (FILE*)0xEEEEEEEE;
EXPECT_CALL(*g_fileIOMock, fopen(_,_))
.Times(1)
.WillOnce(Return(topfp));
EXPECT_CALL(*g_fileIOMock, fclose(_))
.Times(1)
.WillOnce(Return(0));

//getMEMinfo
EXPECT_CALL(*g_fileIOMock, read(_,_,_))
.WillOnce([](int fd, void* buf, size_t count) {
Expand Down
6 changes: 6 additions & 0 deletions source/test/mocks/FileioMock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,15 @@ extern "C" int fscanf(FILE *stream, const char *format, ...)
va_list args;
va_start(args, format);
static int call_count = 0;
static FileMock *last_mock = nullptr;
if (g_fileIOMock == nullptr){
return fscanf_func(stream, format, args);
}
/* Reset call_count when a new mock instance is active (i.e. new test started) */
if (g_fileIOMock != last_mock) {
call_count = 0;
last_mock = g_fileIOMock;
}
if (strcmp(format, "%d") == 0) {
int *out_ptr = va_arg(args, int *);
if (call_count == 0) {
Expand Down
Loading