commit - bfaa588350d78e9201ca46190f33e81973308b73
commit + 144e01a4d075265e50af98aed5f1581b3f841d25
blob - fbf66df99ecb39aceaeff386c1862daefee6e535
blob + 6d481629fd47f57e9906321f36f4897c0473eec7
--- libtestoutput/CMakeLists.txt
+++ libtestoutput/CMakeLists.txt
parse_testanything.c
sha1.h
sha1.c
+crc32.h
+crc32.c
)
include(FindEXPAT)
blob - fefb9e20c6a4dc2cac15ae7f184eb6eebc457bda
blob + 07ffcd48c476b3cd6da7f49e7113170244329f07
--- libtestoutput/parse_common.c
+++ libtestoutput/parse_common.c
fclose(file);
return NULL;
}
+
enum test_format format;
format = detect_format(path);
switch (format) {
report->format = FORMAT_UNKNOWN;
return report;
}
+
+ /*
+ if ((report->suites = parse_junit(file)) != NULL) {
+ report->format = FORMAT_JUNIT;
+ } else if ((report->suites = parse_testanything(file)) != NULL) {
+ report->format = FORMAT_TAP13;
+ } else if ((report->suites = parse_subunit_v1(file)) != NULL) {
+ report->format = FORMAT_SUBUNIT_V1;
+ } else if ((report->suites = parse_subunit_v2_from_file(path)) != NULL) {
+ report->format = FORMAT_SUBUNIT_V2;
+ } else {
+ report->format = FORMAT_UNKNOWN;
+ }
+ */
fclose(file);
report->path = (unsigned char*)strdup(path);
blob - /dev/null
blob + bcaeeca1c7aaf49f5ef83d71ec583f4432062407 (mode 644)
--- /dev/null
+++ libtestoutput/crc32.c
+/*
+ * CRC32
+ * http://bxr.su/OpenBSD/bin/md5/crc.c
+ * http://csbruce.com/software/crc32.c
+ * http://home.thep.lu.se/~bjorn/crc/
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+uint32_t crc32_for_byte(uint32_t r) {
+ for(int j = 0; j < 8; ++j)
+ r = (r & 1? 0: (uint32_t)0xEDB88320L) ^ r >> 1;
+ return r ^ (uint32_t)0xFF000000L;
+}
+
+void crc32(const void *data, size_t n_bytes, uint32_t* crc) {
+ static uint32_t table[0x100];
+ if(!*table)
+ for(size_t i = 0; i < 0x100; ++i)
+ table[i] = crc32_for_byte(i);
+ for(size_t i = 0; i < n_bytes; ++i)
+ *crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8;
+}
+
+int main(int ac, char** av) {
+ FILE *fp;
+ char buf[1L << 15];
+ for(int i = ac > 1; i < ac; ++i)
+ if((fp = i? fopen(av[i], "rb"): stdin)) {
+ uint32_t crc = 0;
+ while(!feof(fp) && !ferror(fp))
+ crc32(buf, fread(buf, 1, sizeof(buf), fp), &crc);
+ if(!ferror(fp))
+ printf("%08x%s%s\n", crc, ac > 2? "\t": "", ac > 2? av[i]: "");
+ if(i)
+ fclose(fp);
+ }
+ return 0;
+}
blob - /dev/null
blob + 830b7577f223171e6ba9b16565c54a214c600024 (mode 644)
--- /dev/null
+++ libtestoutput/crc32.h
+#ifndef CRC32_H
+#define CRC32_H
+
+uint32_t crc32_for_byte(uint32_t r);
+void crc32(const void *data, size_t n_bytes, uint32_t* crc);
+
+#endif /* CRC32_H */
blob - c622f9416d043aa4d1bce0ebc441efa1bdd25bf9
blob + e0cc7c0714e7fa7280f6577584250200654c5c82
--- libtestoutput/parse_subunit_v2.c
+++ libtestoutput/parse_subunit_v2.c
{
assert(buffer == NULL);
buffer = read_uint8(buffer, n_bytes);
+ printf("Bytes %d\n", *n_bytes);
assert(*n_bytes != 0);
-
+ uint8_t value = 0;
for(int i = 0; i <= *n_bytes; i++) {
- buffer = read_uint8(buffer, n_bytes);
+ buffer = read_uint8(buffer, &value);
}
return buffer;
int read_subunit_v2_packet(const void *buf, subunit_packet *p)
{
- uint8_t sig = 0;
buf = read_uint8(buf, &p->signature);
if (p->signature != SUBUNIT_SIGNATURE)
{
if (p->flags & FLAG_EOF) { /* nothing to do */ };
if (p->flags & FLAG_RUNNABLE) { /* nothing to do */ };
- printf("CRC32: %s\n", (char*)buf);
+ /* printf("CRC32: %s\n", (char*)buf); */
return 0;
}
/*
-
-CRC32
-const char *s = "0xb30x2901b329010c03666f6f";
-printf("%lX, should be %X\n", crc32(0, (const void*)s, strlen(s)), sample_crc32);
-http://bxr.su/OpenBSD/bin/md5/crc.c
-
-https://rosettacode.org/wiki/CRC-32#C
-http://csbruce.com/software/crc32.c
-
-UTF-8
-https://github.com/benkasminbullock/unicode-c/blob/master/unicode.c
-https://github.com/clibs/cutef8
-
-*/
-
-/* Simple public domain implementation of the standard CRC32 checksum.
- * Outputs the checksum for each file given as a command line argument.
- * Invalid file names and files that cause errors are silently skipped.
- * The program reads from stdin if it is called with no arguments. */
-
-/* http://home.thep.lu.se/~bjorn/crc/ */
-
-/*
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-uint32_t crc32_for_byte(uint32_t r) {
- for(int j = 0; j < 8; ++j)
- r = (r & 1? 0: (uint32_t)0xEDB88320L) ^ r >> 1;
- return r ^ (uint32_t)0xFF000000L;
-}
-
-void crc32(const void *data, size_t n_bytes, uint32_t* crc) {
- static uint32_t table[0x100];
- if(!*table)
- for(size_t i = 0; i < 0x100; ++i)
- table[i] = crc32_for_byte(i);
- for(size_t i = 0; i < n_bytes; ++i)
- *crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8;
-}
-
-int main(int ac, char** av) {
- FILE *fp;
- char buf[1L << 15];
- for(int i = ac > 1; i < ac; ++i)
- if((fp = i? fopen(av[i], "rb"): stdin)) {
- uint32_t crc = 0;
- while(!feof(fp) && !ferror(fp))
- crc32(buf, fread(buf, 1, sizeof(buf), fp), &crc);
- if(!ferror(fp))
- printf("%08x%s%s\n", crc, ac > 2? "\t": "", ac > 2? av[i]: "");
- if(i)
- fclose(fp);
- }
- return 0;
-}
-
-*/
+ * UTF-8
+ * https://www.json.org/JSON_checker/utf8_decode.c
+ * https://github.com/douglascrockford/JSON-c/blob/master/utf8_decode.c
+ */
blob - 43219c3304f92569e07783bb65102507cb859160
blob + 1b66f314636fd1839dadc285b19992d8b4470779
--- libtestoutput/parse_subunit_v2.h
+++ libtestoutput/parse_subunit_v2.h
#define _STATUS_UXFAILURE 0x007
typedef struct subunit_packet {
- uint8_t signature;
- uint16_t flags;
+ uint8_t signature;
uint8_t status;
+ uint8_t version;
+ uint16_t flags;
uint32_t length;
uint32_t timestamp;
- uint8_t version;
char *testid;
char *tags;
char *mime;