TC: Expand tc for kernel/environ module API's
1) Adds tc for setenv().
- includes invalid input tc.
2) invalid input tc for putenv().
@@ -51,10 +51,9 @@ static void tc_environ_setenv_getenv_unsetenv(void)
const char *psz_name = "abc";
const char *psz_value = "xyz";
const char *pusz_name = "arv";
- int overwrite_num = 1;
char *psz_getvalue = NULL;
- ret_chk = setenv(psz_name, psz_value, overwrite_num);
+ ret_chk = setenv(psz_name, psz_value, 1);
TC_ASSERT_EQ_CLEANUP("setenv", ret_chk, OK, clearenv());
psz_getvalue = getenv(psz_name);
@@ -63,8 +62,7 @@ static void tc_environ_setenv_getenv_unsetenv(void)
/* with overwrite_num = 0, psz_value should not be updated */
psz_value = "pqr";
- overwrite_num = 0;
- ret_chk = setenv(psz_name, psz_value, overwrite_num);
+ ret_chk = setenv(psz_name, psz_value, 0);
TC_ASSERT_EQ_CLEANUP("setenv", ret_chk, OK, clearenv());
/* set and get value should not be equal as overwrite is 0 */
@@ -87,6 +85,15 @@ static void tc_environ_setenv_getenv_unsetenv(void)
psz_getvalue = getenv("arv");
TC_ASSERT_EQ("getenv", psz_getvalue, NULL);
+ ret_chk = setenv(NULL, psz_value, 0);
+ TC_ASSERT_EQ("setenv", ret_chk, ERROR);
+
+ ret_chk = setenv(psz_name, NULL, 1);
+ TC_ASSERT_EQ("setenv", ret_chk, OK);
+
+ ret_chk = setenv(psz_name, NULL, 0);
+ TC_ASSERT_EQ("setenv", ret_chk, OK);
+
clearenv();
TC_SUCCESS_RESULT();
}
@@ -151,6 +158,9 @@ static void tc_environ_putenv(void)
psz_getvalue = getenv("PATH");
TC_ASSERT_EQ("getenv", strcmp(psz_getvalue, "D:"), 0);
+ ret_chk = putenv(NULL);
+ TC_ASSERT_EQ("putenv", ret_chk, ERROR);
+
clearenv();
TC_SUCCESS_RESULT();
}
