mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
tests: add simple testcase for getttyname_malloc()
This commit is contained in:
parent
30222f4b2c
commit
0d53f53bbd
@ -6,6 +6,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "macro.h"
|
||||
#include "path-util.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "tests.h"
|
||||
@ -52,7 +53,16 @@ static void test_read_one_char(void) {
|
||||
rewind(file);
|
||||
assert_se(read_one_char(file, &r, 1000000, &need_nl) < 0);
|
||||
|
||||
unlink(name);
|
||||
assert_se(unlink(name) >= 0);
|
||||
}
|
||||
|
||||
static void test_getttyname_malloc(void) {
|
||||
_cleanup_free_ char *ttyname = NULL;
|
||||
_cleanup_close_ int master = -1;
|
||||
|
||||
assert_se((master = posix_openpt(O_RDWR|O_NOCTTY)) >= 0);
|
||||
assert_se(getttyname_malloc(master, &ttyname) >= 0);
|
||||
assert_se(PATH_IN_SET(ttyname, "ptmx", "pts/ptmx"));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -60,6 +70,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_default_term_for_tty();
|
||||
test_read_one_char();
|
||||
test_getttyname_malloc();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user