make check can now run in parallel
This commit is contained in:
parent
f63eb1d9c5
commit
03feeb7ef2
12
GNUmakefile
12
GNUmakefile
@ -401,6 +401,16 @@ sa2:
|
||||
$(MAKE) DIET= CC="gcc -fanalyzer" -j8
|
||||
|
||||
UNITTESTS=$(shell grep -l UNITTEST */*.c)
|
||||
TESTS=$(patsubst %.c,test_%,$(notdir $(UNITTESTS)))
|
||||
|
||||
check: haveuint128.h haveinline.h entities.h
|
||||
test_%: %.c
|
||||
$(CC) -g -o $@ $< -DUNITTEST -I. -fprofile-arcs -ftest-coverage $(LDFLAGS)
|
||||
./$@
|
||||
rm -f $@
|
||||
|
||||
test_scan_html: entities.h
|
||||
|
||||
check2: haveuint128.h haveinline.h entities.h
|
||||
for i in $(UNITTESTS); do $(CC) -Wall -fprofile-arcs -ftest-coverage -g -o t -DUNITTEST $$i -I. $(LDFLAGS) && ./t || echo FAIL $$i ; done
|
||||
|
||||
check: haveuint128.h haveinline.h $(TESTS)
|
||||
|
2
buffer.h
2
buffer.h
@ -148,7 +148,7 @@ __writememsz__(2,3)
|
||||
ssize_t buffer_get_token_pred(buffer* b,char* x,size_t len,string_predicate p);
|
||||
|
||||
char *buffer_peek(buffer* b);
|
||||
void buffer_seek(buffer* b,size_t len);
|
||||
ssize_t buffer_seek(buffer* b,size_t len);
|
||||
|
||||
#define buffer_PEEK(s) ( (s)->x + (s)->p )
|
||||
#define buffer_SEEK(s,len) ( (s)->p += (len) )
|
||||
|
@ -4,7 +4,7 @@ buffer_feed \- low-level component of buffer_get
|
||||
.SH SYNTAX
|
||||
.B #include <libowfat/buffer.h>
|
||||
|
||||
int \fBbuffer_feed\fP(buffer* \fIb\fR);
|
||||
ssize_t \fBbuffer_feed\fP(buffer* \fIb\fR);
|
||||
.SH DESCRIPTION
|
||||
If the string is nonempty, buffer_feed returns the length of the string.
|
||||
If the string is empty, buffer_feed uses the read operation to feed data
|
||||
|
@ -4,9 +4,13 @@ buffer_seek \- remove bytes from beginning of string in buffer
|
||||
.SH SYNTAX
|
||||
.B #include <libowfat/buffer.h>
|
||||
|
||||
void \fBbuffer_seek\fP(buffer* \fIb\fR,size_t \fIr\fR);
|
||||
ssize_t \fBbuffer_seek\fP(buffer* \fIb\fR,size_t \fIr\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_seek removes \fIr\fR bytes from the beginning of the string.
|
||||
\fIr\fR must be at most the current length of the string.
|
||||
|
||||
\fIr\fR can not be larger than the maximum value that ssize_t can
|
||||
represent.
|
||||
.SH "RETURN VALUE"
|
||||
Returns r (or -1 on error).
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_feed(3), buffer_peek(3), buffer_get(3), buffer(3)
|
||||
|
@ -1,8 +1,34 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "buffer.h"
|
||||
|
||||
void buffer_seek(buffer* b,size_t len) {
|
||||
size_t n=b->p+len;
|
||||
if (n<b->p) n=b->p;
|
||||
if (n>b->n) n=b->n;
|
||||
b->p=n;
|
||||
ssize_t buffer_seek(buffer* b,size_t len) {
|
||||
size_t leftinbuf = b->n - b->p;
|
||||
ssize_t r;
|
||||
|
||||
if ((ssize_t)len < 0) return -1; // can't signal back how much we read, so error out
|
||||
r = (ssize_t)len;
|
||||
|
||||
if (len <= leftinbuf) {
|
||||
b->p += len;
|
||||
return len;
|
||||
} else {
|
||||
// want to skip more than there was in the buffer
|
||||
len -= leftinbuf;
|
||||
b->p = 0; // clear buffer
|
||||
b->n = 0;
|
||||
/* change position in underlying file */
|
||||
if (b->fd != -1 &&
|
||||
lseek(b->fd, len, SEEK_CUR) != -1) return len;
|
||||
// either we have no fd or input is not seekable
|
||||
// call read repeatedly
|
||||
while (len > 0) {
|
||||
ssize_t r = buffer_feed(b);
|
||||
if (r < 0) return -1;
|
||||
if ((size_t)r > len) r = len; // can't happen
|
||||
len -= r;
|
||||
b->p = b->n = 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
16
parse.h
16
parse.h
@ -89,6 +89,22 @@ int bs_capacitycheck(struct bytestream* bs,size_t capacity);
|
||||
/* Like bs_capacitycheck but will set stream to error state on fail */
|
||||
int bs_capacityassert(struct bytestream* bs,size_t capacity);
|
||||
|
||||
/* Return number of bytes left before limit, or 0 on error. */
|
||||
/* If the backend is an iobuf without limit, return max size_t value. */
|
||||
size_t bs_capacityleft(struct bytestream* bs);
|
||||
|
||||
/* Assert there are no more bytes left in a bytestream. */
|
||||
/* Useful to make sure that you parsed the whole packet
|
||||
* and there were no slack bytes in the end.
|
||||
* Return 1 if there really were no more bytes in the stream.
|
||||
* If there ARE bytes left, will set error flag in stream and return 0 */
|
||||
int bs_nomoredataassert(struct bytestream* bs);
|
||||
|
||||
/* Consume all bytes left before limit */
|
||||
/* Useful for nested structs or when the backing store is an iobuf */
|
||||
/* Return number of bytes consumed */
|
||||
size_t bs_consumeleftovers(struct bytestream* bs);
|
||||
|
||||
/* Read n bytes from stream. Return n.
|
||||
* Set stream to error state if not enough space or I/O error. */
|
||||
ssize_t prs_readblob(struct bytestream* bs,unsigned char* dest,size_t destlen);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "entities.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user