8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / json / tst.usdt.d
blobf0fbdd5cababcd78374ddd40b0680309feb76b92
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
16 #pragma D option strsize=4k
17 #pragma D option quiet
18 #pragma D option destructive
21 * This test reads a JSON string from a USDT probe, roughly simulating the
22 * primary motivating use case for the json() subroutine: filtering
23 * JSON-formatted log messages from a logging subsystem like node-bunyan.
26 pid$1:a.out:waiting:entry
28 this->value = (int *)alloca(sizeof (int));
29 *this->value = 1;
30 copyout(this->value, arg0, sizeof (int));
33 bunyan*$1:::log-*
35 this->j = copyinstr(arg0);
38 bunyan*$1:::log-*
39 /json(this->j, "finished") == NULL && json(this->j, "action") != "ignore"/
41 this->index = strtoll(json(this->j, "index"));
42 this->size = json(this->j, "sizes[2]");
43 this->odd = json(this->j, "facts.odd");
44 this->even = json(this->j, "facts.even");
45 printf("[%d] sz %s odd %s even %s\n", this->index, this->size,
46 this->odd, this->even);
49 bunyan*$1:::log-*
50 /json(this->j, "finished") != NULL/
52 printf("FINISHED!\n");
53 exit(0);
56 tick-10s
58 printf("ERROR: Timed out before finish message!\n");
59 exit(1);
62 ERROR
64 exit(1);