~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/unistd/isatty.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <assert.h>
 
2
#include <errno.h>
 
3
#include <fcntl.h>
1
4
#include <stdio.h>
2
 
#include <errno.h>
 
5
#include <stdlib.h>
 
6
#include <string.h>
3
7
#include <unistd.h>
4
 
#include <fcntl.h>
5
8
 
6
9
int main() {
7
 
  printf("read: %d\n", isatty(open("/read", O_RDONLY)));
8
 
  printf("errno: %d\n", errno);
9
 
  errno = 0;
10
 
 
11
 
  printf("write: %d\n", isatty(open("/write", O_WRONLY)));
12
 
  printf("errno: %d\n", errno);
13
 
  errno = 0;
14
 
 
15
 
  printf("all: %d\n", isatty(open("/all", O_RDONLY)));
16
 
  printf("errno: %d\n", errno);
17
 
  errno = 0;
18
 
 
19
 
  printf("folder: %d\n", isatty(open("/folder", O_RDONLY)));
20
 
  printf("errno: %d\n", errno);
21
 
  errno = 0;
22
 
 
23
 
  printf("file: %d\n", isatty(open("/file", O_RDONLY)));
24
 
  printf("errno: %d\n", errno);
25
 
  errno = 0;
26
 
 
27
 
  return 0;
28
 
}
 
10
  int err;
 
11
 
 
12
  err = isatty(-1);
 
13
  assert(!err);
 
14
  assert(errno == EBADF);
 
15
 
 
16
  err = isatty(open("/dev/stdin", O_RDONLY));
 
17
  assert(err == 1);
 
18
 
 
19
  err = isatty(open("/dev/null", O_RDONLY));
 
20
  assert(!err);
 
21
 
 
22
  err = isatty(open("/dev", O_RDONLY));
 
23
  assert(!err);
 
24
 
 
25
  puts("success");
 
26
 
 
27
  return EXIT_SUCCESS;
 
28
}
 
 
b'\\ No newline at end of file'