Commit graph

32 commits

Author SHA1 Message Date
Petr Štetiar
b0a5cd8a28 add cram based unit tests
For improved QA etc. For the start with initial test cases for avl,
base64, jshn and list components. Moved runqueue and blobmsg from
examples to tests.  Converted just a few first test cases from
json-script example into the new cram based unit test, more to come.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24 13:26:58 +01:00
Petr Štetiar
6228df9de9 iron out all extra compiler warnings
gcc-9 on x86/64 has reported following issues:

 base64.c:173:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:230:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:238:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:242:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:252:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:256:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:266:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:315:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:329:15: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 blob.c:207:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.c:210:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.c:243:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 blob.c:246:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.h:253:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blobmsg_json.c:155:10: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 examples/../blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 examples/../blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 json_script.c:590:7: error: this statement may fall through [-Werror=implicit-fallthrough=]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-20 14:34:01 +01:00
André Gaul
7f671b1e68 blobmsg: add support for double
This adds support for double floating point type to make it more JSON
compatible. For type checking it also adds a stub BLOB_ATTR_DOUBLE type.
If necessary, the accessor functions for blob can be added later

Signed-off-by: André Gaul <andre@gaul.io>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-01-04 21:36:31 +01:00
Yousong Zhou
5326ce1046 examples: add shunit2 tests for json_script
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2016-02-20 13:36:08 +01:00
Yousong Zhou
02db6d71b6 json_script: add "isdir" support
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2016-02-20 13:36:08 +01:00
Nikolay Dimitrov
4c94515cc8 libubox: cmake: Add BUILD_EXAMPLES option
Add ability to skip building the examples. The default value is ON to follow
the original cmake behavior.

Signed-off-by: Nikolay Dimitrov <picmaster@mail.bg>
2015-06-14 15:25:38 +02:00
Yousong Zhou
fecaf2f5f6 examples: add example code for json_script.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-22 15:46:35 +01:00
Yousong Zhou
8cc3903383 examples: fix build.
- runqueue-example.c: fix include path for in-tree build.
 - blobmsg-example.c: add inttypes.h for using PRIu64.
 - add examples/ subdirectory to main CMakeLists.txt

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:57:19 +01:00
Yousong Zhou
c5d80836cd lua: do not hardcode /opt/local/include for Apple.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:57:07 +01:00
Felix Fietkau
fd5b522ce6 blobmsg-example: use blobmsg_get_string()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-03 13:50:49 +02:00
Luka Perkov
b538c2b20e examples: fix build error
Patch fixes the following error:

error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘void *’ [-Werror=format=]
   indent_printf(indent, "%s\n", blobmsg_data(data));

Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-07-03 13:48:30 +02:00
Felix Fietkau
8cee1e552a blobmsg_example: fix output
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-03 12:56:40 +02:00
Luka Perkov
db8e7060e0 examples: use PRIu64 instead %lld when printing uint64_t values
Patch fixes build failure:

error: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘uint64_t’ [-Werror=format=]
   indent_printf(indent, "%lld\n", *(uint64_t *)data);

Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-07-03 12:53:13 +02:00
Luka Perkov
480b6c7da1 examples: add missing include
Patch fixes following build error:

error: implicit declaration of function ‘close’ [-Werror=implicit-function-declaration]
  close(cl->s.fd.fd);

Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-07-03 12:53:13 +02:00
Luka Perkov
fd3a33b7ed examples: fix linking with json-c
Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-07-03 12:53:13 +02:00
Luka Perkov
b10cd1c0f6 examples: remove set but unused variable
Fixes build failure.

Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-07-03 12:53:13 +02:00
Xiongfei Guo
02ca593347 Support delete a fd event.
When you call the fd_add, it will return an object with `delete` method.
So you can delete that event if you want.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24 14:30:30 +01:00
Xiongfei Guo
79b56268b4 Added fd_add method for uloop lua binding.
Use uloop.fd_add like this:

    local socket = require "socket"

    udp = socket.udp()

    uloop.fd_add(
        udp, -- socket
        function( -- callback function
            ufd,    -- socket object when register the fd
            events  -- uloop events. eg. uloop.ULOOP_READ .
        )
            local words, msg_or_ip, port_or_nil = ufd:receivefrom()
            print('Recv UDP packet from '..msg_or_ip..':'..port_or_nil..' : '..words)
        end,
        uloop.ULOOP_READ -- event you want to listen
    )

The `examples/uloop-example.lua` show an example of this work.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24 14:30:30 +01:00
Felix Fietkau
460d94d6e8 blobmsg-example: fix length handling in dump_table() calls 2013-09-11 17:59:33 +02:00
Felix Fietkau
c4b79e4b54 runqueue: move completion handler from runqueue_process to runqueue_task to make it more generic
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:27:45 +02:00
Felix Fietkau
cb6c1718e7 runqueue: add a simple task queueing/completion tracking implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:10:00 +02:00
Felix Fietkau
3ceb819690 ustream-example: fix container_of type errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:06:55 +02:00
Felix Fietkau
15ce776772 ustream-example: fix logic inversion 2012-10-23 18:00:20 +02:00
Felix Fietkau
e4027a6327 add a cmake file for the examples and add the binaries to .gitignore 2012-10-21 23:01:30 +02:00
Felix Fietkau
d3b3280055 ustream: add example code 2012-10-21 23:01:12 +02:00
Felix Fietkau
ae3bcf84e1 blobmsg-example: fix compile errors 2012-10-21 03:40:53 +02:00
Felix Fietkau
0a81131257 add an example script for the uloop lua binding 2012-09-27 13:47:46 +02:00
Felix Fietkau
b1ea9afd60 remove uhtbl-test.c, it is obsolete 2012-03-14 11:55:59 +01:00
Felix Fietkau
ff585b97c0 fix json list parsing 2011-01-30 01:13:32 +01:00
Felix Fietkau
5129bc9401 blobmsg: make arrays structually the same as tables - simplifies library user code 2011-01-29 18:00:40 +01:00
Felix Fietkau
461e986a80 remove #if 0'd debug code 2011-01-29 13:05:24 +01:00
Felix Fietkau
e82d74f898 Initial import 2010-10-13 21:29:08 +02:00