Skip to content
Snippets Groups Projects
Commit 00c729cc authored by Moe Jette's avatar Moe Jette
Browse files

Created README, basic build information.

Modified src/api functions to build without warnings, mostly unused
	variables that were declared.
Changed un/packstr into separate unpackstr_ptr and unpackstr_xmalloc,
	the first returns a pointer into the buffer, the second allocates
	memory and copies the string into it. Updated src/test/pack-test.c
	accordingly.
Converted integers in various job/node/partition structures into
	uint32_t for ease of passing across network with API.
parent 090ae9ab
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include <src/common/pack.h> #include <src/common/pack.h>
#include <src/common/xmalloc.h>
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
...@@ -23,20 +24,23 @@ int main (int argc, char *argv[]) ...@@ -23,20 +24,23 @@ int main (int argc, char *argv[])
int len_buf = 0; int len_buf = 0;
uint16_t test16 = 1234, out16; uint16_t test16 = 1234, out16;
uint32_t test32 = 5678, out32, byte_cnt; uint32_t test32 = 5678, out32, byte_cnt;
char testbytes[] = "TEST STRING", *outbytes; char testbytes[] = "TEST BYTES", *outbytes;
char teststring[] = "TEST STRING", *outstring = NULL;
bufp = buffer; bufp = buffer;
len_buf = sizeof(buffer); len_buf = sizeof(buffer);
pack16(test16, &bufp, &len_buf); pack16(test16, &bufp, &len_buf);
pack32(test32, &bufp, &len_buf); pack32(test32, &bufp, &len_buf);
packstr(testbytes, (uint32_t)(strlen(testbytes)+1), &bufp, &len_buf); packstr(testbytes, (uint32_t)(strlen(testbytes)+1), &bufp, &len_buf);
packstr(teststring, (uint32_t)(strlen(teststring)+1), &bufp, &len_buf);
printf("wrote %d bytes\n", len_buf); printf("wrote %d bytes\n", len_buf);
bufp = buffer; bufp = buffer;
len_buf = sizeof(buffer); len_buf = sizeof(buffer);
unpack16(&out16, &bufp, &len_buf); unpack16(&out16, &bufp, &len_buf);
unpack32(&out32, &bufp, &len_buf); unpack32(&out32, &bufp, &len_buf);
unpackstr(&outbytes, &byte_cnt, &bufp, &len_buf); unpackstr_ptr(&outbytes, &byte_cnt, &bufp, &len_buf);
unpackstr_xmalloc(&outstring, &byte_cnt, &bufp, &len_buf);
if (out16 != test16) { if (out16 != test16) {
printf("un/pack16 failed\n"); printf("un/pack16 failed\n");
...@@ -50,10 +54,17 @@ int main (int argc, char *argv[]) ...@@ -50,10 +54,17 @@ int main (int argc, char *argv[])
passed++; passed++;
if (strcmp(testbytes, outbytes) != 0) { if (strcmp(testbytes, outbytes) != 0) {
printf("un/packstr failed\n"); printf("un/packstr_ptr failed\n");
} else } else
passed++; passed++;
if (strcmp(teststring, outstring) != 0) {
printf("un/packstr_xmalloc failed\n");
} else {
passed++;
xfree(outstring);
}
printf("%d tests passed, %d failed.\n", passed, failed); printf("%d tests passed, %d failed.\n", passed, failed);
return failed; return failed;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment