criu/test/zdtm/static/pty04.c
Dmitry Safonov 0ca79b6d6c arm/test: fix _XOPEN_SOURCE define
It looks like, on arm32 in <features.h>:
  #ifdef  _XOPEN_SOURCE
  # define __USE_XOPEN    1
  # if (_XOPEN_SOURCE - 0) >= 500
  #  define __USE_XOPEN_EXTENDED  1
  /* ... */

And ptsname(), unlockpt(), grantpt() are under:
  #ifdef __USE_XOPEN_EXTENDED
  extern int grantpt (int __fd) __THROW;
  extern int unlockpt (int __fd) __THROW;
  extern char *ptsname (int __fd) __THROW __wur;
  #endif
  /* ... */

Fixes:
pty00.c:50:2: error: implicit declaration of function 'grantpt' [-Werror=implicit-function-declaration]
  grantpt(fdm);
  ^~~~~~~
pty00.c:51:2: error: implicit declaration of function 'unlockpt' [-Werror=implicit-function-declaration]
  unlockpt(fdm);
  ^~~~~~~~
pty00.c:52:14: error: implicit declaration of function 'ptsname' [-Werror=implicit-function-declaration]
  slavename = ptsname(fdm);
              ^~~~~~~
pty00.c:52:12: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
  slavename = ptsname(fdm);
            ^

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-09-06 19:31:21 +03:00

64 lines
1.1 KiB
C

#define _XOPEN_SOURCE 500
#include <stdlib.h>
#include "zdtmtst.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <signal.h>
#include <sys/ioctl.h>
const char *test_doc = "Check two pts with a fake ptmx";
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
int main(int argc, char *argv[])
{
int master, slave1, slave2;
char *slavename;
test_init(argc, argv);
master = open("/dev/ptmx", O_RDWR);
if (master == -1) {
pr_perror("open(%s) failed", "/dev/ptmx");
return 1;
}
grantpt(master);
unlockpt(master);
slavename = ptsname(master);
slave1 = open(slavename, O_RDWR);
if (slave1 == -1) {
pr_perror("open(%s) failed", slavename);
return 1;
}
slave2 = open(slavename, O_RDWR);
if (slave2 == -1) {
pr_perror("open(%s) failed", slavename);
return 1;
}
if (ioctl(slave1, TIOCSCTTY, 1)) {
pr_perror("Can't set a controll terminal");
return 1;
}
test_msg("Closing master\n");
signal(SIGHUP, SIG_IGN);
close(master);
test_daemon();
test_waitsig();
close(slave1);
close(slave2);
pass();
return 0;
}