Skip to content

Commit c26479d

Browse files
committed
Updated branch with requested changes
1 parent 662a8c1 commit c26479d

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

src/tests/file-sys-add-fixed-map-api-test/file-sys-add-fixed-map-api-test.c

+40-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
/*
2-
* Copyright (c) 2020, United States government as represented by the
3-
* administrator of the National Aeronautics Space Administration.
4-
* All rights reserved. This software was created at NASA Goddard
5-
* Space Flight Center pursuant to government contracts.
2+
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer"
63
*
7-
* This is governed by the NASA Open Source Agreement and may be used,
8-
* distributed and modified only according to the terms of that agreement.
4+
* Copyright (c) 2019 United States Government as represented by
5+
* the Administrator of the National Aeronautics and Space Administration.
6+
* All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
919
*/
1020

21+
1122
/*
1223
* Filename: file-sys-add-fixed-map-api-test.c
1324
*
@@ -18,55 +29,65 @@
1829
#include <stdio.h>
1930
#include <string.h>
2031
#include <stdlib.h>
21-
2232
#include "common_types.h"
2333
#include "osapi.h"
2434
#include "utassert.h"
2535
#include "uttest.h"
2636
#include "utbsp.h"
2737

2838

29-
30-
3139
/* *************************************** MAIN ************************************** */
3240

3341
void TestFileSysAddFixedMapApi(void)
3442
{
3543
int32 expected;
3644
int32 actual;
3745
uint32 fs_id;
38-
char virtual_path[OS_MAX_LOCAL_PATH_LEN];
3946
char translated_path[OS_MAX_LOCAL_PATH_LEN];
4047

4148
/* Test for nominal inputs */
49+
4250
/*
4351
* This test case requires a fixed virtual dir for one test case.
4452
* Just map /test to a dir of the same name, relative to current dir.
4553
*/
4654

47-
strcpy(virtual_path, "/test");
48-
expected = OS_SUCCESS;
49-
actual = OS_TranslatePath(virtual_path, translated_path);
55+
expected = OS_FS_ERR_PATH_INVALID;
56+
actual = OS_TranslatePath("/test/myfile.txt", translated_path);
57+
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual);
5058

5159
expected = OS_SUCCESS;
52-
actual = OS_FileSysAddFixedMap(&fs_id, "./test", virtual_path);
60+
actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test");
5361
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);
5462

5563
expected = OS_SUCCESS;
56-
actual = OS_TranslatePath(virtual_path, translated_path);
64+
actual = OS_TranslatePath("/test/myfile.txt", translated_path);
65+
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_SUCCESS", (long)actual);
5766

5867
/* Test for invalid inputs */
68+
expected = OS_ERR_NAME_TAKEN;
69+
actual = OS_FileSysAddFixedMap(NULL, "./test", "/test");
70+
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
71+
72+
expected = OS_INVALID_POINTER;
73+
actual = OS_FileSysAddFixedMap(&fs_id, NULL, "/test");
74+
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
75+
76+
expected = OS_INVALID_POINTER;
77+
actual = OS_FileSysAddFixedMap(&fs_id, "./test", NULL);
78+
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
79+
5980
expected = OS_INVALID_POINTER;
6081
actual = OS_FileSysAddFixedMap(NULL, NULL, NULL);
61-
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);
82+
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
6283

6384
expected = OS_INVALID_POINTER;
6485
actual = OS_FileSysAddFixedMap(&fs_id, NULL, NULL);
65-
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);
86+
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
6687

6788
expected = OS_INVALID_POINTER;
68-
actual = OS_FileSysAddFixedMap(&fs_id, "./test", NULL);
69-
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);
89+
actual = OS_FileSysAddFixedMap(NULL, "./test", NULL);
90+
UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_INVALID_POINTER", (long)actual);
7091

7192

7293
} /* end TestFileSysAddFixedMapApi */

0 commit comments

Comments
 (0)