Skip to content

Commit

Permalink
Updated branch with requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yammajamma committed Aug 10, 2020
1 parent 662a8c1 commit c26479d
Showing 1 changed file with 40 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
/*
* Copyright (c) 2020, United States government as represented by the
* administrator of the National Aeronautics Space Administration.
* All rights reserved. This software was created at NASA Goddard
* Space Flight Center pursuant to government contracts.
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer"
*
* This is governed by the NASA Open Source Agreement and may be used,
* distributed and modified only according to the terms of that agreement.
* 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
*
Expand All @@ -18,55 +29,65 @@
#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 virtual_path[OS_MAX_LOCAL_PATH_LEN];
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.
*/

strcpy(virtual_path, "/test");
expected = OS_SUCCESS;
actual = OS_TranslatePath(virtual_path, translated_path);
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", virtual_path);
actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test");
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_SUCCESS;
actual = OS_TranslatePath(virtual_path, translated_path);
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_SUCCESS", (long)actual);
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_SUCCESS", (long)actual);
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_SUCCESS", (long)actual);
actual = OS_FileSysAddFixedMap(NULL, "./test", NULL);
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);


} /* end TestFileSysAddFixedMapApi */
Expand Down

0 comments on commit c26479d

Please sign in to comment.