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

@@ -20,20 +20,20 @@
 #
 
 #
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
+# Copyright (c) 2012, Joyent, Inc. All rights reserved.
 #
-#ident  "%Z%%M% %I%     %E% SMI"
 
 ppriv -s A=basic,dtrace_proc,dtrace_user $$
 
 /usr/sbin/dtrace -q -s /dev/stdin <<"EOF"
 
 BEGIN {
         errorcount = 0;
-        expected_errorcount = 23;
+        expected_errorcount = 27;
 }
 
 BEGIN { trace(mutex_owned(&`pidlock)); }
 BEGIN { trace(mutex_owner(&`pidlock)); }
 BEGIN { trace(mutex_type_adaptive(&`pidlock)); }

@@ -53,18 +53,23 @@
 BEGIN { trace(strstr(`initname, "in")); }
 BEGIN { trace(strtok(`initname, "/")); }
 BEGIN { trace(strtok(NULL, "/")); }
 BEGIN { trace(strtok("foo/bar", `initname)); }
 BEGIN { trace(strtok(NULL, `initname)); }
+BEGIN { trace(strtoll(`initname)); }
+BEGIN { trace(strtoll(`initname, 10)); }
 BEGIN { trace(substr(`initname, 2, 3)); }
 
 BEGIN { trace(ddi_pathname(`top_devinfo, 1)); }
 BEGIN { trace(strjoin(`initname, "foo")); }
 BEGIN { trace(strjoin("foo", `initname)); }
 BEGIN { trace(dirname(`initname)); }
 BEGIN { trace(cleanpath(`initname)); }
 
+BEGIN { j = "{\"/sbin/init\":\"uh oh\"}"; trace(json(j, `initname)); }
+BEGIN { trace(json(`initname, "x")); }
+
 ERROR {
         errorcount++;
 }
 
 BEGIN /errorcount == expected_errorcount/ {