LCOV - code coverage report
Current view: directory - src/trusted/service_runtime - nacl_error_log_test.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 18 15 83.3 %
Date: 2014-06-18 Functions: 0 0 -

       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 "native_client/src/include/portability.h"
       8                 : #include "native_client/src/include/portability_io.h"
       9                 : 
      10                 : #include <errno.h>
      11                 : #include <stdio.h>
      12                 : #include <stdlib.h>
      13                 : #include <string.h>
      14                 : 
      15                 : #include "native_client/src/shared/gio/gio.h"
      16                 : #include "native_client/src/shared/platform/nacl_check.h"
      17                 : #include "native_client/src/shared/platform/nacl_exit.h"
      18                 : #include "native_client/src/shared/platform/nacl_log.h"
      19                 : #include "native_client/src/shared/platform/nacl_sync.h"
      20                 : #include "native_client/src/shared/platform/nacl_sync_checked.h"
      21                 : #include "native_client/src/trusted/service_runtime/nacl_all_modules.h"
      22                 : #include "native_client/src/trusted/service_runtime/nacl_error_log_hook.h"
      23                 : #include "native_client/src/trusted/service_runtime/sel_ldr.h"
      24                 : 
      25               1 : static void NaClCrashLogWriter(void *state,
      26               1 :                                char *buf,
      27               1 :                                size_t buf_bytes) {
      28               2 :   UNREFERENCED_PARAMETER(state);
      29                 :   /* we don't need/use the NaClApp object for now */
      30               1 :   (void) fprintf(stdout, "NaClCrashLogWriter: log buffer contents:\n");
      31                 :   /*
      32                 :    * TODO(phosek): fwrite is defined with __wur in glibc < 2.15, eliminate
      33                 :    * the ignore result macro once glibc >= 2.16 becomes more widespread.
      34                 :    */
      35               2 :   IGNORE_RESULT(fwrite(buf, 1, buf_bytes, stdout));
      36               1 :   (void) fflush(stdout);
      37               1 : }
      38                 : 
      39                 : int main(void) {
      40               1 :   struct NaClApp state;
      41               1 :   int retval = 1;
      42                 : 
      43               1 :   NaClAllModulesInit();
      44               1 :   if (!NaClAppCtor(&state)) {
      45               0 :     fprintf(stderr, "FAILED: could not construct NaCl App state\n");
      46               0 :     goto done;
      47                 :   }
      48               1 :   NaClErrorLogHookInit(NaClCrashLogWriter, &state);
      49               1 :   NaClLog(LOG_FATAL,
      50                 :           "This is a test of the emergency log recovery mechanism."
      51                 :           " This is only a test.  If this had been an actual emergency,"
      52                 :           " you would have been instructed to surf to one of the"
      53                 :           " official web sites for your planet.\n");
      54               1 :   retval = 2;
      55                 :  done:
      56               0 :   return retval;
      57                 : }

Generated by: LCOV version 1.7