Skip to content

Commit

Permalink
Merge pull request #764 from skliper/fix760-ut_fails
Browse files Browse the repository at this point in the history
Fix #760, Install modules and clean up files for unit tests
  • Loading branch information
astrogeco authored Jan 25, 2021
2 parents 0867182 + 773dc88 commit 6af008c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/tests/file-api-test/file-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,13 @@ void TestOpenFileAPI(void)
*/
status = OS_CloseFileByName(filename2);
UtAssert_True(status < OS_SUCCESS, "status after OS_CloseFileByName 2 = %d", (int)status);

/* Try removing the files from the drive to end the function */
status = OS_remove(filename1);
UtAssert_True(status == OS_SUCCESS, "status after remove filename1 = %d", (int)status);
status = OS_remove(filename2);
UtAssert_True(status == OS_SUCCESS, "status after remove filename2 = %d", (int)status);
status = OS_remove(filename3);
UtAssert_True(status == OS_SUCCESS, "status after remove filename3 = %d", (int)status);

}
10 changes: 8 additions & 2 deletions src/tests/select-test/select-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ OS_SockAddr_t c_addr;
OS_SockAddr_t c2_addr;
osal_id_t bin_sem_id;

#define OS_TEST_SELECT_FILENAME "/drive0/select_test.txt"

/* *************************************** MAIN ************************************** */

char * fsAddrPtr = NULL;
Expand All @@ -58,7 +60,7 @@ static osal_id_t setup_file(void)
osal_id_t id;
OS_mkfs(fsAddrPtr, "/ramdev0", "RAM", 512, 20);
OS_mount("/ramdev0", "/drive0");
OS_OpenCreate(&id, "/drive0/select_test.txt", OS_FILE_FLAG_CREATE, OS_READ_WRITE);
OS_OpenCreate(&id, OS_TEST_SELECT_FILENAME, OS_FILE_FLAG_CREATE, OS_READ_WRITE);
return id;
}

Expand Down Expand Up @@ -531,6 +533,10 @@ void TestSelectSingleFile(void)
/* Verify Outputs */
UtAssert_True(actual == expected, "OS_SelectSingle() (%ld) == OS_ERROR_TIMEOUT", (long)actual);
UtAssert_True(StateFlags == 0, "OS_SelectSingle() (0x%x) == None", (unsigned int)StateFlags);

/* Close and remove file */
OS_close(fd);
OS_remove(OS_TEST_SELECT_FILENAME);
}

void UtTest_Setup(void)
Expand All @@ -549,4 +555,4 @@ void UtTest_Setup(void)
UtTest_Add(TestSelectSingleWrite, Setup_Single, Teardown_Single, "TestSelectSingleWrite");
UtTest_Add(TestSelectMultipleWrite, Setup_Multi, Teardown_Multi, "TestSelectMultipleWrite");
UtTest_Add(TestSelectSingleFile, NULL, NULL, "TestSelectSingleFile");
}
}
3 changes: 2 additions & 1 deletion src/unit-tests/osfile-test/ut_osfile_fileio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,11 +2057,12 @@ void UT_os_outputtofile_test()
}
}

UT_os_outputtofile_test_exit_tag:

/* Reset test environment */
OS_close(g_fDescs[0]);
OS_remove(g_fNames[0]);

UT_os_outputtofile_test_exit_tag:
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/unit-tests/osloader-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ while(MOD GREATER 0)
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY utmod)
add_dependencies(osal_loader_UT MODULE${MOD})
foreach(TGT ${INSTALL_TARGET_LIST})
install(TARGETS MODULE${MOD} DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}/utmod)
endforeach()
endwhile(MOD GREATER 0)

0 comments on commit 6af008c

Please sign in to comment.