OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
replace_ocroots.c
Go to the documentation of this file.
1 
2 #include <genutils.h>
3 
4 #include <check.h>
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 
10 const char* ocvarroot = "/base/ocssw/var";
11 const char* ocdataroot = "/base/ocssw/share";
12 const char* ocsswroot = "/base/ocssw";
13 
14 START_TEST(ocvar){
15  char str[50];
17  strcat(str, "/cool/dir");
18  char* str2 = replace_ocroots(str);
19  ck_assert_str_eq(str2, "$OCVARROOT/cool/dir");
20  free(str2);
21 }
22 END_TEST
23 
24 START_TEST(ocdata){
25  char str[50];
27  strcat(str, "/cool/dir");
28  char* str2 = replace_ocroots(str);
29  ck_assert_str_eq(str2, "$OCDATAROOT/cool/dir");
30  free(str2);
31 }
32 END_TEST
33 
34 START_TEST(ocssw){
35  char str[50];
37  strcat(str, "/cool/dir");
38  char* str2 = replace_ocroots(str);
39  ck_assert_str_eq(str2, "$OCSSWROOT/cool/dir");
40  free(str2);
41 }
42 END_TEST
43 
44 START_TEST(many){
45  char str[500];
46 
48  strcat(str, "/cool/dir1;");
49  strcat(str, ocsswroot);
50  strcat(str, "/cool/dir2;");
51 
52  strcat(str, ocvarroot);
53  strcat(str, "/cool/dir3;");
54  strcat(str, ocvarroot);
55  strcat(str, "/cool/dir4;");
56 
57  strcat(str, ocdataroot);
58  strcat(str, "/cool/dir5;");
59  strcat(str, ocdataroot);
60  strcat(str, "/cool/dir6");
61 
62  char* str2 = replace_ocroots(str);
63  ck_assert_str_eq(str2, "$OCSSWROOT/cool/dir1;$OCSSWROOT/cool/dir2;$OCVARROOT/cool/dir3;$OCVARROOT/cool/dir4;$OCDATAROOT/cool/dir5;$OCDATAROOT/cool/dir6");
64  free(str2);
65 }
66 END_TEST
67 
68 Suite* stub_suite(void){
69  Suite *s = suite_create("Stub");
70 
71  TCase *tc_core = tcase_create("Core");
72  tcase_add_test(tc_core, ocvar);
73  tcase_add_test(tc_core, ocdata);
74  tcase_add_test(tc_core, ocssw);
75  tcase_add_test(tc_core, many);
76  suite_add_tcase(s, tc_core);
77 
78  return s;
79 }
80 
81 int main(int argc, char **argv){
82  int number_failed;
83 
84  // modify the environment variables
85  setenv("OCVARROOT", ocvarroot, 1);
86  setenv("OCDATAROOT", ocdataroot, 1);
87  setenv("OCSSWROOT", ocsswroot, 1);
88 
89  Suite *s = stub_suite();
90  SRunner *sr = srunner_create(s);
91 
92  srunner_run_all(sr, CK_VERBOSE);
93  number_failed = srunner_ntests_failed(sr);
94  srunner_free(sr);
95  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
96 }
97 
int main(int argc, char **argv)
#define EXIT_SUCCESS
Definition: GEO_basic.h:72
START_TEST(ocvar)
const char * ocdataroot
const char * ocvarroot
const char * ocsswroot
char * replace_ocroots(const char *inStr)
const char * str
Definition: l1c_msi.cpp:35
END_TEST Suite * stub_suite(void)
data_t s[NROOTS]
Definition: decode_rs.h:75
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")