mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-01 11:26:52 +03:00
tests: add setenv and unsetenv wrappers for windows
Signed-off-by: Gauravsingh Sisodia <xaerru@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
committed by
Sahana Prasad
parent
bed4438695
commit
fe53cdfabd
@ -1655,6 +1655,33 @@ void torture_reset_config(ssh_session session)
|
||||
memset(session->opts.options_seen, 0, sizeof(session->opts.options_seen));
|
||||
}
|
||||
|
||||
void torture_unsetenv(const char *variable)
|
||||
{
|
||||
int rc;
|
||||
#ifdef WIN32
|
||||
rc = _putenv_s(variable, "");
|
||||
#else
|
||||
rc = unsetenv(variable);
|
||||
#endif // WIN32
|
||||
assert_return_code(rc, errno);
|
||||
}
|
||||
|
||||
void torture_setenv(const char *variable, const char *value)
|
||||
{
|
||||
int rc;
|
||||
#ifdef WIN32
|
||||
if (value != NULL) {
|
||||
rc = _putenv_s(variable, value);
|
||||
assert_return_code(rc, errno);
|
||||
} else {
|
||||
torture_unsetenv(variable);
|
||||
}
|
||||
#else
|
||||
rc = setenv(variable, value, 1);
|
||||
assert_return_code(rc, errno);
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
#if defined(HAVE_WEAK_ATTRIBUTE) && defined(TORTURE_SHARED)
|
||||
__attribute__((weak)) int torture_run_tests(void)
|
||||
{
|
||||
|
@ -165,4 +165,7 @@ char *torture_create_temp_file(const char *template);
|
||||
char *torture_get_current_working_dir(void);
|
||||
int torture_change_dir(char *path);
|
||||
|
||||
void torture_setenv(char const* variable, char const* value);
|
||||
void torture_unsetenv(char const* variable);
|
||||
|
||||
#endif /* _TORTURE_H */
|
||||
|
Reference in New Issue
Block a user