Print this page
OS-1723 DTrace should speak JSON
Reviewed by: Bryan Cantrill <bmc@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh
          +++ new/usr/src/cmd/dtrace/test/tst/common/privs/tst.func_access.ksh
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15  # If applicable, add the following below this CDDL HEADER, with the
  16   16  # fields enclosed by brackets "[]" replaced with your own identifying
  17   17  # information: Portions Copyright [yyyy] [name of copyright owner]
  18   18  #
  19   19  # CDDL HEADER END
  20   20  #
  21   21  
  22   22  #
  23   23  # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24   24  # Use is subject to license terms.
       25 +# Copyright (c) 2012, Joyent, Inc. All rights reserved.
  25   26  #
  26      -#ident  "%Z%%M% %I%     %E% SMI"
  27   27  
  28   28  ppriv -s A=basic,dtrace_proc,dtrace_user $$
  29   29  
  30   30  /usr/sbin/dtrace -q -s /dev/stdin <<"EOF"
  31   31  
  32   32  BEGIN {
  33   33          errorcount = 0;
  34      -        expected_errorcount = 23;
       34 +        expected_errorcount = 27;
  35   35  }
  36   36  
  37   37  BEGIN { trace(mutex_owned(&`pidlock)); }
  38   38  BEGIN { trace(mutex_owner(&`pidlock)); }
  39   39  BEGIN { trace(mutex_type_adaptive(&`pidlock)); }
  40   40  BEGIN { trace(mutex_type_spin(&`pidlock)); }
  41   41  
  42   42  BEGIN { trace(rw_read_held(&`ksyms_lock)); }
  43   43  BEGIN { trace(rw_write_held(&`ksyms_lock)); }
  44   44  BEGIN { trace(rw_iswriter(&`ksyms_lock)); }
↓ open down ↓ 3 lines elided ↑ open up ↑
  48   48  
  49   49  BEGIN { trace(strlen(`initname)); }
  50   50  BEGIN { trace(strchr(`initname, 0x69)); }
  51   51  BEGIN { trace(strrchr(`initname, 0x69)); }
  52   52  BEGIN { trace(strstr("/sbin/init/foo", `initname)); }
  53   53  BEGIN { trace(strstr(`initname, "in")); }
  54   54  BEGIN { trace(strtok(`initname, "/")); }
  55   55  BEGIN { trace(strtok(NULL, "/")); }
  56   56  BEGIN { trace(strtok("foo/bar", `initname)); }
  57   57  BEGIN { trace(strtok(NULL, `initname)); }
       58 +BEGIN { trace(strtoll(`initname)); }
       59 +BEGIN { trace(strtoll(`initname, 10)); }
  58   60  BEGIN { trace(substr(`initname, 2, 3)); }
  59   61  
  60   62  BEGIN { trace(ddi_pathname(`top_devinfo, 1)); }
  61   63  BEGIN { trace(strjoin(`initname, "foo")); }
  62   64  BEGIN { trace(strjoin("foo", `initname)); }
  63   65  BEGIN { trace(dirname(`initname)); }
  64   66  BEGIN { trace(cleanpath(`initname)); }
  65   67  
       68 +BEGIN { j = "{\"/sbin/init\":\"uh oh\"}"; trace(json(j, `initname)); }
       69 +BEGIN { trace(json(`initname, "x")); }
       70 +
  66   71  ERROR {
  67   72          errorcount++;
  68   73  }
  69   74  
  70   75  BEGIN /errorcount == expected_errorcount/ {
  71   76          trace("test passed");
  72   77          exit(0);
  73   78  }
  74   79  
  75   80  BEGIN /errorcount != expected_errorcount/ {
  76   81          printf("fail: expected %d.  saw %d.", expected_errorcount, errorcount);
  77   82          exit(1);
  78   83  }
  79   84  EOF
  80   85  
  81   86  
  82   87  exit $?
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX