|
1 | 1 | /*
|
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" |
6 | 3 | *
|
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. |
9 | 19 | */
|
10 | 20 |
|
| 21 | + |
11 | 22 | /*
|
12 | 23 | * Filename: file-sys-add-fixed-map-api-test.c
|
13 | 24 | *
|
|
18 | 29 | #include <stdio.h>
|
19 | 30 | #include <string.h>
|
20 | 31 | #include <stdlib.h>
|
21 |
| - |
22 | 32 | #include "common_types.h"
|
23 | 33 | #include "osapi.h"
|
24 | 34 | #include "utassert.h"
|
25 | 35 | #include "uttest.h"
|
26 | 36 | #include "utbsp.h"
|
27 | 37 |
|
28 | 38 |
|
29 |
| - |
30 |
| - |
31 | 39 | /* *************************************** MAIN ************************************** */
|
32 | 40 |
|
33 | 41 | void TestFileSysAddFixedMapApi(void)
|
34 | 42 | {
|
35 | 43 | int32 expected;
|
36 | 44 | int32 actual;
|
37 | 45 | uint32 fs_id;
|
38 |
| - char virtual_path[OS_MAX_LOCAL_PATH_LEN]; |
39 | 46 | char translated_path[OS_MAX_LOCAL_PATH_LEN];
|
40 | 47 |
|
41 | 48 | /* Test for nominal inputs */
|
| 49 | + |
42 | 50 | /*
|
43 | 51 | * This test case requires a fixed virtual dir for one test case.
|
44 | 52 | * Just map /test to a dir of the same name, relative to current dir.
|
45 | 53 | */
|
46 | 54 |
|
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); |
50 | 58 |
|
51 | 59 | expected = OS_SUCCESS;
|
52 |
| - actual = OS_FileSysAddFixedMap(&fs_id, "./test", virtual_path); |
| 60 | + actual = OS_FileSysAddFixedMap(&fs_id, "./test", "/test"); |
53 | 61 | UtAssert_True(actual == expected, "OS_FileSysAddFixedMap() (%ld) == OS_SUCCESS", (long)actual);
|
54 | 62 |
|
55 | 63 | 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); |
57 | 66 |
|
58 | 67 | /* 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 | + |
59 | 80 | expected = OS_INVALID_POINTER;
|
60 | 81 | 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); |
62 | 83 |
|
63 | 84 | expected = OS_INVALID_POINTER;
|
64 | 85 | 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); |
66 | 87 |
|
67 | 88 | 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); |
70 | 91 |
|
71 | 92 |
|
72 | 93 | } /* end TestFileSysAddFixedMapApi */
|
|
0 commit comments