Skip to content

Commit

Permalink
Fix #379, Add FileSysAddFixedMap functional API test (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
yammajamma authored Aug 14, 2020
1 parent 8cfd6fe commit 34e0978
Showing 1 changed file with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer"
*
* Copyright (c) 2019 United States Government as represented by
* the Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/*
* Filename: file-sys-add-fixed-map-api-test.c
*
* Purpose: This file contains functional tests for "osapi-FileSysAddFixedMap"
*
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common_types.h"
#include "osapi.h"
#include "utassert.h"
#include "uttest.h"
#include "utbsp.h"


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

void TestFileSysAddFixedMapApi(void)
{
int32 expected;
int32 actual;
uint32 fs_id;
char translated_path[OS_MAX_LOCAL_PATH_LEN];

/* Test for nominal inputs */

/*
* This test case requires a fixed virtual dir for one test case.
* Just map /test to a dir of the same name, relative to current dir.
*/

expected = OS_FS_ERR_PATH_INVALID;
actual = OS_TranslatePath("/test/myfile.txt", translated_path);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_SUCCESS;
actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_SUCCESS;
actual = OS_TranslatePath("/test/myfile.txt", translated_path);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual);

/* Test for invalid inputs */
expected = OS_ERR_NAME_TAKEN;
actual = OS_FileSysAddFixedMap(NULL, "./test", "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(&fs_id, NULL, "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(&fs_id, "./test", NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(NULL, NULL, NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(&fs_id, NULL, NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_FileSysAddFixedMap(NULL, "./test", NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);


} /* end TestFileSysAddFixedMapApi */


void UtTest_Setup(void)
{
if (OS_API_Init() != OS_SUCCESS)
{
UtAssert_Abort("OS_API_Init() failed");
}

/*
* Register the test setup and check routines in UT assert
*/
UtTest_Add(TestFileSysAddFixedMapApi, NULL, NULL, "TestFileSysAddFixedMapApi");
}

0 comments on commit 34e0978

Please sign in to comment.