Skip to content

Commit

Permalink
Update CI, fix some compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Jan 6, 2024
1 parent c723829 commit 4046c9a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/canon_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ static int ptp_eos_evproc_run_payload(struct PtpRuntime *r, void **buf, char *fm

rc = ptp_eos_evproc_return_data(r);

(*buf) = ptp_dup_payload(r);
void *dup = malloc(ptp_get_payload_length(r));
memcpy(dup, ptp_get_payload(r), ptp_get_payload_length(r));

(*buf) = dup;

return rc;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int ptp_send_data(struct PtpRuntime *r, struct PtpCommand *cmd, void *data, int

// These numbers are not exact, but it's fine
if (length + 50 > r->data_length) {
ptp_buffer_resize(100 + length);
ptp_buffer_resize(r, 100 + length);
}

// Send operation request (data phase later on)
Expand Down
2 changes: 1 addition & 1 deletion test/ci-config.mak
Original file line number Diff line number Diff line change
@@ -1 +1 @@
LDFLAGS=-L../vcam/ -Wl,-rpath=../vcam/ -lvusb -lexif
LDFLAGS=-L../vcam/ -Wl,-rpath=../vcam/ -lusb -lexif
2 changes: 1 addition & 1 deletion test/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

cp test/ci-config.mak config.mak
cd ..
# In the future, this will be a fixed branch or stable release
git clone https://github.com/petabyt/vcam
cd vcam
make libusb.so
mv libusb.so libvusb.so
cd ../camlib
make test-ci
./test-ci
2 changes: 1 addition & 1 deletion test/myci-config.mak
Original file line number Diff line number Diff line change
@@ -1 +1 @@
LDFLAGS=-L../vusb/ -lvusb -Wl,-rpath=../vusb/ -lexif
LDFLAGS=-L../vcam/ -lusb -Wl,-rpath=../vcam/ -lexif
3 changes: 1 addition & 2 deletions test/myci.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/sh

cp test/myci-config.mak config.mak
cd ../vusb/
cd ../vcam/
make libusb.so
mv libusb.so libvusb.so
cd ../camlib
make test-ci && ./test-ci
echo "test return value: $?"
Expand Down
18 changes: 10 additions & 8 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ int ptp_vcam_magic() {
if (rc) return rc;

int sizes[] = {4, 10, 101, 513, 1000, 997, 257, 511, 1, 2, 3};

size_t l = sizeof(sizes) / sizeof(int);

// Try to send a bunch of different payloads and make sure the data is recieved correctly
for (size_t i = 0; i < l; i++) {
struct PtpCommand cmd;
cmd.code = 0x9999;
cmd.code = 0xBEEF;
cmd.param_length = 1;

srand(time(NULL));

unsigned char *buffer = malloc(sizes[i]);

// Random data, basic checksum
int checksum = 0;
for (int x = 0; x < sizes[i]; x++) {
buffer[x] = rand() / 256;
Expand All @@ -35,16 +37,16 @@ int ptp_vcam_magic() {

cmd.params[0] = checksum;

rc = ptp_generic_send_data(&r, &cmd, buffer, sizes[i]);
rc = ptp_send_data(&r, &cmd, buffer, sizes[i]);
if (rc) return rc;
}

ptp_generic_close(&r);
ptp_close(&r);
return 0;
}

int test_setup_usb(struct PtpRuntime *r) {
ptp_generic_init(r);
ptp_init(r);

if (ptp_device_init(r)) {
puts("Device connection error");
Expand Down Expand Up @@ -106,7 +108,7 @@ int test_eos_t6() {
printf("%s\n", buffer);

//ptp_device_close(&r);
ptp_generic_close(&r);
ptp_close(&r);
return 0;
}

Expand All @@ -130,7 +132,7 @@ int test_bind() {
rc = bind_run(&r, "ptp_disconnect", bbuffer, sizeof(bbuffer));
printf("ptp_disconnect: %s\n", bbuffer);

ptp_generic_close(&r);
ptp_close(&r);
return 0;
}

Expand Down Expand Up @@ -180,7 +182,7 @@ int test_fs() {

free(arr);

ptp_generic_close(&r);
ptp_close(&r);
return 0;
}

Expand Down

0 comments on commit 4046c9a

Please sign in to comment.