Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (c) 2017 The Chromium OS 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 <errno.h>
      8 #include <string.h>
      9 #include <time.h>
     10 
     11 #include <sys/timex.h>
     12 
     13 /* This program is expected to run under android alt-syscall. */
     14 int main(void) {
     15   struct timex buf;
     16   int ret;
     17 
     18   /* Test read operation. Should succeed (i.e. not returning -1). */
     19   memset(&buf, 0, sizeof(buf));
     20   ret = clock_adjtime(CLOCK_REALTIME, &buf);
     21   if (ret == -1)
     22     return 1;
     23 
     24   /* Test with nullptr buffer. Should fail with EFAULT. */
     25   ret = clock_adjtime(CLOCK_REALTIME, NULL);
     26   if (ret != -1 || errno != EFAULT)
     27     return 2;
     28 
     29   /*
     30    * Test a write operation. Under android alt-syscall, should fail with
     31    * EPERM.
     32    */
     33   buf.modes = ADJ_MAXERROR;
     34   ret = clock_adjtime(CLOCK_REALTIME, &buf);
     35   if (ret != -1 || errno != EPERM)
     36     return 3;
     37 
     38   /* Passed successfully */
     39   return 0;
     40 }
     41