Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / unittests / shared / imc / nacl_close_test.c
1 /*
2  * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 #include <stdio.h>
8
9 #include "native_client/src/shared/imc/nacl_imc_c.h"
10 #include "native_client/src/shared/platform/nacl_error.h"
11
12 /* Writes the last error message to the standard error. */
13 static void failWithErrno(const char* message) {
14   char buffer[256];
15
16   if (0 == NaClGetLastErrorString(buffer, sizeof(buffer))) {
17     fprintf(stderr, "%s: %s", message, buffer);
18   }
19   exit(EXIT_FAILURE);
20 }
21
22 int main(int argc, char* argv[]) {
23   NaClHandle pair[2];
24
25   UNREFERENCED_PARAMETER(argc);
26   UNREFERENCED_PARAMETER(argv);
27
28   if (0 != NaClSocketPair(pair)) {
29     failWithErrno("SocketPair");
30   }
31
32   if (0 != NaClClose(pair[0])) {
33     failWithErrno("NaClClose");
34   }
35
36   if (0 != NaClClose(pair[1])) {
37     failWithErrno("NaClClose");
38   }
39
40   return 0;
41 }