Simplified expect tests
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
char *config_orig;
|
||||
char *data_orig;
|
||||
|
||||
int fd = 0;
|
||||
|
||||
gboolean
|
||||
_create_dir(char *name)
|
||||
{
|
||||
@@ -141,6 +143,8 @@ init_prof_test(void **state)
|
||||
_create_data_dir();
|
||||
_create_chatlogs_dir();
|
||||
_create_logs_dir();
|
||||
|
||||
prof_start();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -153,3 +157,31 @@ close_prof_test(void **state)
|
||||
|
||||
stbbr_stop();
|
||||
}
|
||||
|
||||
void
|
||||
prof_start(void)
|
||||
{
|
||||
fd = exp_spawnl("./profanity", NULL);
|
||||
FILE *fp = fdopen(fd, "r+");
|
||||
|
||||
if (fp == NULL) {
|
||||
assert_true(FALSE);
|
||||
}
|
||||
|
||||
setbuf(fp, (char *)0);
|
||||
}
|
||||
|
||||
void
|
||||
prof_input(char *input)
|
||||
{
|
||||
GString *inp_str = g_string_new(input);
|
||||
g_string_append(inp_str, "\r");
|
||||
write(fd, inp_str->str, inp_str->len);
|
||||
g_string_free(inp_str, TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
prof_output(char *text)
|
||||
{
|
||||
return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user