-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.uc
executable file
·58 lines (45 loc) · 1 KB
/
test.uc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!./ucrun
let n_runs = 0;
function timeout(priv) {
printf("timeout[%d]: %d - %s\n", n_runs, time(), priv);
if (++n_runs >= 3) {
printf("not scheduling new timeout\n");
return false;
}
return 5000;
}
function process(retcode, priv) {
printf("process completed %d %s\n", retcode, priv);
}
global.ulog = {
identity: "ucrun",
channels: [ "stdio", "syslog" ],
};
global.ubus = {
object: "ucrun",
connect: function() {
printf("connected to ubus\n");
},
methods: {
foo: {
cb: function(msg) {
printf("%s\n", msg);
printf("fooo\n");
return { foo: true };
}
}
}
};
global.start = function() {
printf("%s\n", ARGV);
ulog_info("info: %08d\n", 123);
ulog_note("note: [%8s]\n", "abc");
ulog_warn("warn: %c\n", 64);
ulog_err("err: %.3f\n", 1.0/3.0);
uloop_timeout(timeout, 1000, { private: "data" });
uloop_process(process, [ "sleep", "10" ], { sleep: 10 });
uloop_process(process, [ "echo", "abc" ], { echo: "abc" });
};
global.stop = function() {
ulog_info("stopping\n");
};