Skip to content

Commit

Permalink
Upd test, CI, bug in compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Apr 4, 2024
1 parent c7b6ef2 commit 9819a57
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libuv1-dev libpcre2-dev libyajl-dev libcurl4-nss-dev valgrind
sudo apt-get install -y libuv1-dev libpcre2-dev libyajl-dev libcurl4-nss-dev libwebsockets-dev valgrind
- name: Run tests
run: |
cd ./Release/
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apk update && \

FROM amd64/alpine:latest
RUN apk update && \
apk add pcre2 libuv yajl curl tzdata && \
apk add pcre2 libuv yajl curl libwebsockets tzdata && \
mkdir -p /var/lib/thingsdb
COPY --from=0 /tmp/thingsdb/Release/thingsdb /usr/local/bin/

Expand Down
5 changes: 3 additions & 2 deletions docker/full.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y \
libuv1-dev \
libpcre2-dev \
libyajl-dev \
libcurl4-nss-dev && \
libcurl4-nss-dev \
libwebsockets-dev && \
cd /tmp/thingsdb/Release && \
make clean && \
Expand All @@ -19,7 +19,8 @@ RUN mkdir -p /var/lib/thingsdb && \
libuv1 \
libpcre2-8-0 \
libyajl2 \
libcurl3-nss && \
libcurl3-nss \
libwebsockets16 && \
pip3 install py-timod

COPY --from=0 /tmp/thingsdb/Release/thingsdb /usr/local/bin/
Expand Down
2 changes: 1 addition & 1 deletion docker/gcloud.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apk update && \

FROM google/cloud-sdk:alpine
RUN apk update && \
apk add pcre2 libuv yajl curl tzdata && \
apk add pcre2 libuv yajl curl libwebsockets tzdata && \
mkdir -p /var/lib/thingsdb
COPY --from=0 /tmp/thingsdb/Release/thingsdb /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion docker/tls.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FROM ghcr.io/cesbit/tlsproxy:v0.1.1

FROM amd64/alpine:latest
RUN apk update && \
apk add pcre2 libuv yajl curl tzdata && \
apk add pcre2 libuv yajl curl libwebsockets tzdata && \
mkdir -p /var/lib/thingsdb
COPY --from=0 /tmp/thingsdb/Release/thingsdb /usr/local/bin/
COPY --from=1 /tlsproxy /usr/local/bin/
Expand Down
8 changes: 8 additions & 0 deletions inc/ti/pkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ void ti_pkg_log(ti_pkg_t * pkg);
void ti_pkg_set_tp(ti_pkg_t * pkg, uint8_t tp);
static inline size_t ti_pkg_sz(ti_pkg_t * pkg);

/*
In fact, this code should work but gives an annoying warning due to a bug in
the gcc compiler.
#define ti_pkg_check(pkg__) (\
(pkg__)->tp == ((pkg__)->ntp ^ 0xff) && \
(pkg__)->n <= TI_PKG_MAX_SIZE)
*/

#define ti_pkg_check(pkg__) (\
(pkg__)->tp + (pkg__)->ntp == 0xff && \
(pkg__)->n <= TI_PKG_MAX_SIZE)

/* return total package size, header + data size */
static inline size_t ti_pkg_sz(ti_pkg_t * pkg)
Expand Down
2 changes: 1 addition & 1 deletion inc/util/mpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static inline int mp_sbuffer_alloc_init(
{
assert(alloc >= size);
buffer->alloc = alloc;
buffer->data = alloc == size ? NULL : malloc(alloc);
buffer->data = (alloc == size) ? NULL : malloc(alloc);
buffer->size = size;
return alloc != size && buffer->data == NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions itest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04 as builder
FROM python as builder
RUN apt-get update && \
apt-get install -y \
libuv1-dev \
Expand All @@ -23,7 +23,7 @@ RUN apt-get update && \
libpcre2-8-0 \
libyajl2 \
libcurl3-nss \
libwebsockets
libwebsockets17
COPY --from=builder ./Release/thingsdb /Release/thingsdb
COPY ./itest/ /itest/
COPY ./inc/doc.h /inc/doc.h
Expand Down
3 changes: 2 additions & 1 deletion src/ti/mod/github.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,14 @@ static CURLcode gh__download_file(
}

ok = fx_is_dir(dest) || mkdir(dest, FX_DEFAULT_DIR_ACCESS) == 0;
free(dest);
if (!ok)
{
log_warn_errno_file("cannot create directory", errno, dest);
curle_code = CURLE_WRITE_ERROR;
free(dest);
goto cleanup;
}
free(dest);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/ti/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static void module__cb(ti_future_t * future)
* Future have fixed pack flags; thus always with ID's etc.
*/
if (ti_thing_to_client_pk(thing, &vp, ti_future_deep(future) + 1, 0))
goto mem_error1;
goto mem_error0;

future->pkg = (ti_pkg_t *) buffer.data;
pkg_init(future->pkg, 0, TI_PROTO_MODULE_REQ, buffer.size);
Expand All @@ -207,8 +207,6 @@ static void module__cb(ti_future_t * future)
}
return;

mem_error1:
msgpack_sbuffer_destroy(&buffer);
mem_error0:
{
ex_t e;
Expand Down

0 comments on commit 9819a57

Please sign in to comment.