src/server/test/webdav.c

changeset 633
392ec9026b07
parent 415
d938228c382e
equal deleted inserted replaced
632:1defab20b477 633:392ec9026b07
327 requests, 327 requests,
328 response); 328 response);
329 } 329 }
330 330
331 331
332 UCX_TEST(test_webdav_plist_add) { 332 CX_TEST(test_webdav_plist_add) {
333 Session *sn = testutil_session(); 333 Session *sn = testutil_session();
334 334
335 UCX_TEST_BEGIN; 335 CX_TEST_DO {
336 336
337 WebdavPList *begin = NULL; 337 WebdavPList *begin = NULL;
338 WebdavPList *end = NULL; 338 WebdavPList *end = NULL;
339 339
340 WebdavProperty p1, p2, p3; 340 WebdavProperty p1, p2, p3;
343 ZERO(&p3, sizeof(WebdavProperty)); 343 ZERO(&p3, sizeof(WebdavProperty));
344 int r; 344 int r;
345 345
346 r = webdav_plist_add(sn->pool, &begin, &end, &p1); 346 r = webdav_plist_add(sn->pool, &begin, &end, &p1);
347 347
348 UCX_TEST_ASSERT(r == 0, "add 1 failed"); 348 CX_TEST_ASSERT(r == 0);
349 UCX_TEST_ASSERT(begin && end, "ptrs are NULL"); 349 CX_TEST_ASSERT(begin && end);
350 UCX_TEST_ASSERT(begin == end, "begin != end"); 350 CX_TEST_ASSERT(begin == end);
351 UCX_TEST_ASSERT(begin->prev == NULL, "begin->prev not NULL"); 351 CX_TEST_ASSERT(begin->prev == NULL);
352 UCX_TEST_ASSERT(begin->next == NULL, "begin->next not NULL"); 352 CX_TEST_ASSERT(begin->next == NULL);
353 353
354 r = webdav_plist_add(sn->pool, &begin, &end, &p2); 354 r = webdav_plist_add(sn->pool, &begin, &end, &p2);
355 355
356 UCX_TEST_ASSERT(r == 0, "add 2 failed"); 356 CX_TEST_ASSERT(r == 0);
357 UCX_TEST_ASSERT(begin && end, "add2: ptrs are NULL"); 357 CX_TEST_ASSERT(begin && end);
358 UCX_TEST_ASSERT(begin->next, "begin->next is NULL"); 358 CX_TEST_ASSERT(begin->next);
359 UCX_TEST_ASSERT(begin->next == end, "begin->next != end"); 359 CX_TEST_ASSERT(begin->next == end);
360 UCX_TEST_ASSERT(end->prev = begin, "end->prev != begin"); 360 CX_TEST_ASSERT(end->prev = begin);
361 UCX_TEST_ASSERT(begin->prev == NULL, "add2: begin->prev not NULL"); 361 CX_TEST_ASSERT(begin->prev == NULL);
362 UCX_TEST_ASSERT(end->next == NULL, "add2: end->next not NULL"); 362 CX_TEST_ASSERT(end->next == NULL);
363 363
364 r = webdav_plist_add(sn->pool, &begin, &end, &p3); 364 r = webdav_plist_add(sn->pool, &begin, &end, &p3);
365 365
366 UCX_TEST_ASSERT(r == 0, "add 3 failed"); 366 CX_TEST_ASSERT(r == 0);
367 UCX_TEST_ASSERT(begin && end, "add3: ptrs are NULL"); 367 CX_TEST_ASSERT(begin && end);
368 UCX_TEST_ASSERT(begin->next == end->prev, "begin->next != end->prev"); 368 CX_TEST_ASSERT(begin->next == end->prev);
369 369
370 UCX_TEST_END; 370 }
371 371
372 testutil_destroy_session(sn); 372 testutil_destroy_session(sn);
373 } 373 }
374 374
375 UCX_TEST(test_webdav_plist_size) { 375 CX_TEST(test_webdav_plist_size) {
376 Session *sn = testutil_session(); 376 Session *sn = testutil_session();
377 377
378 UCX_TEST_BEGIN; 378 CX_TEST_DO {
379 379
380 WebdavPList *begin = NULL; 380 WebdavPList *begin = NULL;
381 WebdavPList *end = NULL; 381 WebdavPList *end = NULL;
382 382
383 WebdavProperty p1, p2, p3; 383 WebdavProperty p1, p2, p3;
384 ZERO(&p1, sizeof(WebdavProperty)); 384 ZERO(&p1, sizeof(WebdavProperty));
385 ZERO(&p2, sizeof(WebdavProperty)); 385 ZERO(&p2, sizeof(WebdavProperty));
386 ZERO(&p3, sizeof(WebdavProperty)); 386 ZERO(&p3, sizeof(WebdavProperty));
387 int r; 387 int r;
388 388
389 UCX_TEST_ASSERT(webdav_plist_size(begin) == 0, "size != 0"); 389 CX_TEST_ASSERT(webdav_plist_size(begin) == 0);
390 r = webdav_plist_add(sn->pool, &begin, &end, &p1); 390 r = webdav_plist_add(sn->pool, &begin, &end, &p1);
391 UCX_TEST_ASSERT(webdav_plist_size(begin) == 1, "size != 1"); 391 CX_TEST_ASSERT(webdav_plist_size(begin) == 1);
392 r = webdav_plist_add(sn->pool, &begin, &end, &p2); 392 r = webdav_plist_add(sn->pool, &begin, &end, &p2);
393 UCX_TEST_ASSERT(webdav_plist_size(begin) == 2, "size != 2"); 393 CX_TEST_ASSERT(webdav_plist_size(begin) == 2);
394 r = webdav_plist_add(sn->pool, &begin, &end, &p3); 394 r = webdav_plist_add(sn->pool, &begin, &end, &p3);
395 UCX_TEST_ASSERT(webdav_plist_size(begin) == 3, "size != 3"); 395 CX_TEST_ASSERT(webdav_plist_size(begin) == 3);
396 396
397 UCX_TEST_END; 397 }
398 398
399 testutil_destroy_session(sn); 399 testutil_destroy_session(sn);
400 } 400 }
401 401
402 UCX_TEST(test_propfind_parse) { 402 CX_TEST(test_propfind_parse) {
403 Session *sn = testutil_session(); 403 Session *sn = testutil_session();
404 Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); 404 Request *rq = testutil_request(sn->pool, "PROPFIND", "/");
405 405
406 UCX_TEST_BEGIN 406 CX_TEST_DO {
407 407
408 int error = 0; 408 int error = 0;
409 409
410 // 410 //
411 // ----------------- TEST_PROPFIND1 ----------------- 411 // ----------------- TEST_PROPFIND1 -----------------
412 // test basic propfind request 412 // test basic propfind request
413 WebdavPropfindRequest *p1 = propfind_parse( 413 WebdavPropfindRequest *p1 = propfind_parse(
414 sn, 414 sn,
415 rq, 415 rq,
416 TEST_PROPFIND1, 416 TEST_PROPFIND1,
417 strlen(TEST_PROPFIND1), 417 strlen(TEST_PROPFIND1),
418 &error); 418 &error);
419 419
420 UCX_TEST_ASSERT(p1, "p1 is NULL"); 420 CX_TEST_ASSERT(p1);
421 UCX_TEST_ASSERT(p1->properties, "p1: no props"); 421 CX_TEST_ASSERT(p1->properties);
422 UCX_TEST_ASSERT(!p1->allprop, "p1: allprop is TRUE"); 422 CX_TEST_ASSERT(!p1->allprop);
423 UCX_TEST_ASSERT(!p1->propname, "p1: propname is TRUE"); 423 CX_TEST_ASSERT(!p1->propname);
424 UCX_TEST_ASSERT(p1->propcount == 6, "p1: wrong propcount"); 424 CX_TEST_ASSERT(p1->propcount == 6);
425 425
426 // property 1: DAV:displayname 426 // property 1: DAV:displayname
427 WebdavPList *elm = p1->properties; 427 WebdavPList *elm = p1->properties;
428 UCX_TEST_ASSERT( 428 CX_TEST_ASSERT(
429 !strcmp(elm->property->name, "displayname"), 429 !strcmp(elm->property->name, "displayname"));
430 "p1: property 1 has wrong name"); 430 CX_TEST_ASSERT(
431 UCX_TEST_ASSERT( 431 !strcmp((char*)elm->property->namespace->href, "DAV:"));
432 !strcmp((char*)elm->property->namespace->href, "DAV:"), 432
433 "p1: property 1 has wrong namespace"); 433 // property 2: DAV:getcontentlength
434 434 elm = elm->next;
435 // property 2: DAV:getcontentlength 435 CX_TEST_ASSERT(elm);
436 elm = elm->next; 436 CX_TEST_ASSERT(
437 UCX_TEST_ASSERT(elm, "p1: property 2 missing"); 437 !strcmp(elm->property->name, "getcontentlength"));
438 UCX_TEST_ASSERT( 438 CX_TEST_ASSERT(
439 !strcmp(elm->property->name, "getcontentlength"), 439 !strcmp((char*)elm->property->namespace->href, "DAV:"));
440 "p1: property 2 has wrong name"); 440
441 UCX_TEST_ASSERT( 441 elm = elm->next;
442 !strcmp((char*)elm->property->namespace->href, "DAV:"), 442 CX_TEST_ASSERT(elm);
443 "p1: property 2 has wrong namespace"); 443 elm = elm->next;
444 444 CX_TEST_ASSERT(elm);
445 elm = elm->next; 445 elm = elm->next;
446 UCX_TEST_ASSERT(elm, "p1: property 3 missing"); 446 CX_TEST_ASSERT(elm);
447 elm = elm->next; 447
448 UCX_TEST_ASSERT(elm, "p1: property 4 missing"); 448 // property 6: DAV:getetag
449 elm = elm->next; 449 elm = elm->next;
450 UCX_TEST_ASSERT(elm, "p1: property 5 missing"); 450 CX_TEST_ASSERT(elm);
451 451 CX_TEST_ASSERT(
452 // property 6: DAV:getetag 452 !strcmp(elm->property->name, "getetag"));
453 elm = elm->next; 453 CX_TEST_ASSERT(
454 UCX_TEST_ASSERT(elm, "p1: property 6 missing"); 454 !strcmp((char*)elm->property->namespace->href, "DAV:"));
455 UCX_TEST_ASSERT( 455 CX_TEST_ASSERT(!elm->next);
456 !strcmp(elm->property->name, "getetag"), 456
457 "p1: property 6 has wrong name"); 457 //
458 UCX_TEST_ASSERT( 458 // ----------------- TEST_PROPFIND2 -----------------
459 !strcmp((char*)elm->property->namespace->href, "DAV:"), 459 // test with multiple namespaces
460 "p1: property 6 has wrong namespace"); 460 WebdavPropfindRequest *p2 = propfind_parse(
461 UCX_TEST_ASSERT(!elm->next, "p1: should not have property 7"); 461 sn,
462 462 rq,
463 // 463 TEST_PROPFIND2,
464 // ----------------- TEST_PROPFIND2 ----------------- 464 strlen(TEST_PROPFIND2),
465 // test with multiple namespaces 465 &error);
466 WebdavPropfindRequest *p2 = propfind_parse( 466
467 sn, 467 CX_TEST_ASSERT(p2);
468 rq, 468 CX_TEST_ASSERT(p2->properties);
469 TEST_PROPFIND2, 469 CX_TEST_ASSERT(!p2->allprop);
470 strlen(TEST_PROPFIND2), 470 CX_TEST_ASSERT(!p2->propname);
471 &error); 471
472 472 // property 1: DAV:resourcetype
473 UCX_TEST_ASSERT(p2, "p2 is NULL"); 473 elm = p2->properties;
474 UCX_TEST_ASSERT(p2->properties, "p2: no props"); 474 CX_TEST_ASSERT(
475 UCX_TEST_ASSERT(!p2->allprop, "p2: allprop is TRUE"); 475 !strcmp(elm->property->name, "resourcetype"));
476 UCX_TEST_ASSERT(!p2->propname, "p2: propname is TRUE"); 476 CX_TEST_ASSERT(
477 477 !strcmp((char*)elm->property->namespace->href, "DAV:"));
478 // property 1: DAV:resourcetype 478
479 elm = p2->properties; 479 // property 2: X:testprop
480 UCX_TEST_ASSERT( 480 elm = elm->next;
481 !strcmp(elm->property->name, "resourcetype"), 481 CX_TEST_ASSERT(elm);
482 "p2: property 1 has wrong name"); 482 CX_TEST_ASSERT(
483 UCX_TEST_ASSERT( 483 !strcmp(elm->property->name, "testprop"));
484 !strcmp((char*)elm->property->namespace->href, "DAV:"), 484 CX_TEST_ASSERT(
485 "p2: property 1 has wrong namespace"); 485 !strcmp((char*)elm->property->namespace->href, "http://example.com/"));
486 486
487 // property 2: X:testprop 487 // property 3: X:name
488 elm = elm->next; 488 elm = elm->next;
489 UCX_TEST_ASSERT(elm, "p2: property 2 missing"); 489 CX_TEST_ASSERT(elm);
490 UCX_TEST_ASSERT( 490 CX_TEST_ASSERT(
491 !strcmp(elm->property->name, "testprop"), 491 !strcmp(elm->property->name, "name"));
492 "p2: property 2 has wrong name"); 492 CX_TEST_ASSERT(
493 UCX_TEST_ASSERT( 493 !strcmp((char*)elm->property->namespace->href, "http://example.com/"));
494 !strcmp((char*)elm->property->namespace->href, "http://example.com/"), 494
495 "p2: property 2 has wrong namespace"); 495 // property 4: Z:testprop
496 496 elm = elm->next;
497 // property 3: X:name 497 CX_TEST_ASSERT(elm);
498 elm = elm->next; 498 CX_TEST_ASSERT(
499 UCX_TEST_ASSERT(elm, "p2: property 3 missing"); 499 !strcmp(elm->property->name, "testprop"));
500 UCX_TEST_ASSERT( 500 CX_TEST_ASSERT(
501 !strcmp(elm->property->name, "name"), 501 !strcmp((char*)elm->property->namespace->href, "testns"));
502 "p2: property 3 has wrong name"); 502
503 UCX_TEST_ASSERT( 503
504 !strcmp((char*)elm->property->namespace->href, "http://example.com/"), 504 //
505 "p2: property 3 has wrong namespace"); 505 // ----------------- TEST_PROPFIND3 -----------------
506 506 // test allprop
507 // property 4: Z:testprop 507 WebdavPropfindRequest *p3 = propfind_parse(sn, rq, TEST_PROPFIND3, strlen(TEST_PROPFIND3), &error);
508 elm = elm->next; 508
509 UCX_TEST_ASSERT(elm, "p2: property 4 missing"); 509 CX_TEST_ASSERT(p3);
510 UCX_TEST_ASSERT( 510 CX_TEST_ASSERT(!p3->properties);
511 !strcmp(elm->property->name, "testprop"), 511 CX_TEST_ASSERT(p3->allprop);
512 "p2: property 4 has wrong name"); 512 CX_TEST_ASSERT(!p3->propname);
513 UCX_TEST_ASSERT( 513 CX_TEST_ASSERT(p3->propcount == 0);
514 !strcmp((char*)elm->property->namespace->href, "testns"), 514
515 "p2: property 4 has wrong namespace"); 515
516 516 //
517 517 // ----------------- TEST_PROPFIND4 -----------------
518 // 518 // test propname
519 // ----------------- TEST_PROPFIND3 ----------------- 519 WebdavPropfindRequest *p4 = propfind_parse(sn, rq, TEST_PROPFIND4, strlen(TEST_PROPFIND4), &error);
520 // test allprop 520
521 WebdavPropfindRequest *p3 = propfind_parse(sn, rq, TEST_PROPFIND3, strlen(TEST_PROPFIND3), &error); 521 CX_TEST_ASSERT(p4);
522 522 CX_TEST_ASSERT(!p4->properties);
523 UCX_TEST_ASSERT(p3, "p3 is NULL"); 523 CX_TEST_ASSERT(!p4->allprop);
524 UCX_TEST_ASSERT(!p3->properties, "p2: has props"); 524 CX_TEST_ASSERT(p4->propname);
525 UCX_TEST_ASSERT(p3->allprop, "p2: allprop is FALSE"); 525
526 UCX_TEST_ASSERT(!p3->propname, "p2: propname is TRUE"); 526
527 UCX_TEST_ASSERT(p3->propcount == 0, "p2: wrong propcount"); 527 //
528 528 // ----------------- TEST_PROPFIND5 -----------------
529 529 // test duplicate check
530 // 530 WebdavPropfindRequest *p5 = propfind_parse(sn, rq, TEST_PROPFIND5, strlen(TEST_PROPFIND5), &error);
531 // ----------------- TEST_PROPFIND4 ----------------- 531
532 // test propname 532 CX_TEST_ASSERT(p5);
533 WebdavPropfindRequest *p4 = propfind_parse(sn, rq, TEST_PROPFIND4, strlen(TEST_PROPFIND4), &error); 533 CX_TEST_ASSERT(p5->properties);
534 534 CX_TEST_ASSERT(!p5->allprop);
535 UCX_TEST_ASSERT(p4, "p4 is NULL"); 535 CX_TEST_ASSERT(!p5->propname);
536 UCX_TEST_ASSERT(!p4->properties, "p2: has props"); 536 CX_TEST_ASSERT(p5->propcount == 4);
537 UCX_TEST_ASSERT(!p4->allprop, "p2: allprop is TRUE"); 537
538 UCX_TEST_ASSERT(p4->propname, "p2: propname is FALSE"); 538 // property 1: DAV:displayname
539 539 elm = p5->properties;
540 540 CX_TEST_ASSERT(elm);
541 // 541 CX_TEST_ASSERT(
542 // ----------------- TEST_PROPFIND5 ----------------- 542 !strcmp(elm->property->name, "displayname"));
543 // test duplicate check 543 CX_TEST_ASSERT(
544 WebdavPropfindRequest *p5 = propfind_parse(sn, rq, TEST_PROPFIND5, strlen(TEST_PROPFIND5), &error); 544 !strcmp((char*)elm->property->namespace->href, "DAV:"));
545 545
546 UCX_TEST_ASSERT(p5, "p5 is NULL"); 546 elm = elm->next;
547 UCX_TEST_ASSERT(p5->properties, "p5: no props"); 547 CX_TEST_ASSERT(elm);
548 UCX_TEST_ASSERT(!p5->allprop, "p5: allprop is TRUE"); 548 elm = elm->next;
549 UCX_TEST_ASSERT(!p5->propname, "p5: propname is TRUE"); 549 CX_TEST_ASSERT(elm);
550 UCX_TEST_ASSERT(p5->propcount == 4, "p5: wrong propcount"); 550
551 551 // property 4: DAV:resourcetype
552 // property 1: DAV:displayname 552 elm = elm->next;
553 elm = p5->properties; 553 CX_TEST_ASSERT(elm);
554 UCX_TEST_ASSERT(elm, "p5: property 1 missing"); 554 CX_TEST_ASSERT(
555 UCX_TEST_ASSERT( 555 !strcmp(elm->property->name, "resourcetype"));
556 !strcmp(elm->property->name, "displayname"), 556 CX_TEST_ASSERT(
557 "p5: property 1 has wrong name"); 557 !strcmp((char*)elm->property->namespace->href, "DAV:"));
558 UCX_TEST_ASSERT( 558
559 !strcmp((char*)elm->property->namespace->href, "DAV:"), 559
560 "p5: property 1 has wrong namespace"); 560 //
561 561 // ----------------- TEST_PROPFIND6 -----------------
562 elm = elm->next; 562 // test prop/allprop mix
563 UCX_TEST_ASSERT(elm, "p5: property 2 missing"); 563 WebdavPropfindRequest *p6 = propfind_parse(sn, rq, TEST_PROPFIND6, strlen(TEST_PROPFIND6), &error);
564 elm = elm->next; 564
565 UCX_TEST_ASSERT(elm, "p5: property 3 missing"); 565 CX_TEST_ASSERT(p6);
566 566 CX_TEST_ASSERT(!p6->properties);
567 // property 4: DAV:resourcetype 567 CX_TEST_ASSERT(p6->allprop);
568 elm = elm->next; 568 CX_TEST_ASSERT(!p6->propname);
569 UCX_TEST_ASSERT(elm, "p5: property 4 missing"); 569 CX_TEST_ASSERT(p6->propcount == 0);
570 UCX_TEST_ASSERT( 570
571 !strcmp(elm->property->name, "resourcetype"), 571 }
572 "p5: property 4 has wrong name");
573 UCX_TEST_ASSERT(
574 !strcmp((char*)elm->property->namespace->href, "DAV:"),
575 "p5: property 4 has wrong namespace");
576
577
578 //
579 // ----------------- TEST_PROPFIND6 -----------------
580 // test prop/allprop mix
581 WebdavPropfindRequest *p6 = propfind_parse(sn, rq, TEST_PROPFIND6, strlen(TEST_PROPFIND6), &error);
582
583 UCX_TEST_ASSERT(p6, "p5 is NULL");
584 UCX_TEST_ASSERT(!p6->properties, "p5: has props");
585 UCX_TEST_ASSERT(p6->allprop, "p5: allprop is FALSE");
586 UCX_TEST_ASSERT(!p6->propname, "p5: propname is TRUE");
587 UCX_TEST_ASSERT(p6->propcount == 0, "p5: wrong propcount");
588
589 UCX_TEST_END
590 572
591 pool_destroy(sn->pool); 573 pool_destroy(sn->pool);
592 } 574 }
593 575
594 UCX_TEST(test_proppatch_parse) { 576 CX_TEST(test_proppatch_parse) {
595 Session *sn = testutil_session(); 577 Session *sn = testutil_session();
596 Request *rq = testutil_request(sn->pool, "PROPPATCH", "/"); 578 Request *rq = testutil_request(sn->pool, "PROPPATCH", "/");
597 579
598 UCX_TEST_BEGIN 580 CX_TEST_DO {
599 int error = 0; 581 int error = 0;
600 582
601 WebdavProppatchRequest *p1 = proppatch_parse(sn, rq, TEST_PROPPATCH1, strlen(TEST_PROPPATCH1), &error); 583 WebdavProppatchRequest *p1 = proppatch_parse(sn, rq, TEST_PROPPATCH1, strlen(TEST_PROPPATCH1), &error);
602 584
603 UCX_TEST_ASSERT(p1->set, "p1: missing set props"); 585 CX_TEST_ASSERT(p1->set);
604 UCX_TEST_ASSERT(!p1->remove, "p1: has remove props"); 586 CX_TEST_ASSERT(!p1->remove);
605 UCX_TEST_ASSERT(p1->setcount == 2, "p1: wrong setcount"); 587 CX_TEST_ASSERT(p1->setcount == 2);
606 UCX_TEST_ASSERT(p1->set->next, "p1: set plist broken"); 588 CX_TEST_ASSERT(p1->set->next);
607 UCX_TEST_ASSERT(!p1->set->next->next, "p1: set plist has no end"); 589 CX_TEST_ASSERT(!p1->set->next->next);
608 UCX_TEST_ASSERT(p1->set->property, "p1: missing property ptr in plist"); 590 CX_TEST_ASSERT(p1->set->property);
609 UCX_TEST_ASSERT( 591 CX_TEST_ASSERT(
610 !strcmp(p1->set->property->name, "test"), 592 !strcmp(p1->set->property->name, "test"));
611 "p1: wrong property 1 name"); 593
612 594 WebdavProppatchRequest *p2 = proppatch_parse(sn, rq, TEST_PROPPATCH2, strlen(TEST_PROPPATCH2), &error);
613 WebdavProppatchRequest *p2 = proppatch_parse(sn, rq, TEST_PROPPATCH2, strlen(TEST_PROPPATCH2), &error); 595
614 596 CX_TEST_ASSERT(p2->set);
615 UCX_TEST_ASSERT(p2->set, "p2: missing set props"); 597 CX_TEST_ASSERT(p2->remove);
616 UCX_TEST_ASSERT(p2->remove, "p2: missing remove props"); 598 CX_TEST_ASSERT(p2->setcount == 4);
617 UCX_TEST_ASSERT(p2->setcount == 4, "p2: wrong setcount"); 599 CX_TEST_ASSERT(p2->removecount == 1);
618 UCX_TEST_ASSERT(p2->removecount == 1, "p2: wrong removecount"); 600
619 601 CX_TEST_ASSERT(
620 UCX_TEST_ASSERT( 602 !strcmp((char*)p2->set->property->namespace->href, "http://example.com/"));
621 !strcmp((char*)p2->set->property->namespace->href, "http://example.com/"), 603 CX_TEST_ASSERT(
622 "p2: set property 1: wrong namespace"); 604 !strcmp(p2->set->property->name, "a"));
623 UCX_TEST_ASSERT( 605 WSXmlNode *p2set1 = p2->set->property->value.node;
624 !strcmp(p2->set->property->name, "a"), 606 CX_TEST_ASSERT(p2set1->type == WS_NODE_TEXT);
625 "p2: set property 1: wrong name"); 607 CX_TEST_ASSERT(p2set1->content);
626 WSXmlNode *p2set1 = p2->set->property->value.node; 608 CX_TEST_ASSERT(!strcmp((char*)p2set1->content, "test"));
627 UCX_TEST_ASSERT( 609
628 p2set1->type == WS_NODE_TEXT, 610 WSXmlNode *p2set3 = p2->set->next->next->property->value.node;
629 "p2: set property 1: wrong type"); 611 CX_TEST_ASSERT(p2set3);
630 UCX_TEST_ASSERT( 612 CX_TEST_ASSERT(p2set3->type == WS_NODE_TEXT);
631 p2set1->content, 613 CX_TEST_ASSERT(p2set3->next);
632 "p2: set property 1: no text"); 614
633 UCX_TEST_ASSERT( 615 CX_TEST_ASSERT(xmlHasProp(p2set3->next, BAD_CAST"test"));
634 !strcmp((char*)p2set1->content, "test"), 616
635 "p2: set property 1: wrong value"); 617 CX_TEST_ASSERT(xmlHasProp(p2set3->next, BAD_CAST"abc"));
636 618
637 WSXmlNode *p2set3 = p2->set->next->next->property->value.node; 619 xmlChar *value1 = xmlGetProp(p2set3->next, BAD_CAST"test");
638 UCX_TEST_ASSERT(p2set3, "p2: set property 3 missing"); 620 CX_TEST_ASSERT(!strcmp((char*) value1, "test1"));
639 UCX_TEST_ASSERT( 621 xmlFree(value1);
640 p2set3->type == WS_NODE_TEXT, 622
641 "p2: set property 3: wrong type"); 623 xmlChar *value2 = xmlGetProp(p2set3->next, BAD_CAST"abc");
642 UCX_TEST_ASSERT( 624 CX_TEST_ASSERT(!strcmp((char*) value2, "def"));
643 p2set3->next, 625 xmlFree(value2);
644 "p2: set property 3: missing element X:name"); 626
645 627 CX_TEST_ASSERT(!strcmp(p2->remove->property->name, "e"));
646 UCX_TEST_ASSERT( 628
647 xmlHasProp(p2set3->next, BAD_CAST"test"), 629 }
648 "p2: set property 3: missing attribute 'test'");
649
650 UCX_TEST_ASSERT(
651 xmlHasProp(p2set3->next, BAD_CAST"abc"),
652 "p2: set property 3: missing attribute 'abc");
653
654 xmlChar *value1 = xmlGetProp(p2set3->next, BAD_CAST"test");
655 UCX_TEST_ASSERT(
656 !strcmp((char*) value1, "test1"),
657 "p2: set property 3: wrong attribute value 1");
658 xmlFree(value1);
659
660 xmlChar *value2 = xmlGetProp(p2set3->next, BAD_CAST"abc");
661 UCX_TEST_ASSERT(
662 !strcmp((char*) value2, "def"),
663 "p2: set property 3: wrong attribute value 2");
664 xmlFree(value2);
665
666 UCX_TEST_ASSERT(
667 !strcmp(p2->remove->property->name, "e"),
668 "p2: wrong remove property");
669
670 UCX_TEST_END
671 630
672 pool_destroy(sn->pool); 631 pool_destroy(sn->pool);
673 } 632 }
674 633
675 UCX_TEST(test_lock_parse) { 634 CX_TEST(test_lock_parse) {
676 Session *sn = testutil_session(); 635 Session *sn = testutil_session();
677 Request *rq = testutil_request(sn->pool, "LOCK", "/"); 636 Request *rq = testutil_request(sn->pool, "LOCK", "/");
678 637
679 UCX_TEST_BEGIN 638 CX_TEST_DO {
680 int error = 0; 639 int error = 0;
681 640
682 WebdavLockRequest *l1 = lock_parse(sn, rq, TEST_LOCK1, strlen(TEST_LOCK1), &error); 641 WebdavLockRequest *l1 = lock_parse(sn, rq, TEST_LOCK1, strlen(TEST_LOCK1), &error);
683 642
684 UCX_TEST_ASSERT(l1, "l1 is NULL"); 643 CX_TEST_ASSERT(l1);
685 UCX_TEST_ASSERT(l1->type == WEBDAV_LOCK_WRITE, "l1: wrong type"); 644 CX_TEST_ASSERT(l1->type == WEBDAV_LOCK_WRITE);
686 UCX_TEST_ASSERT(l1->scope == WEBDAV_LOCK_SHARED, "l1: wrong scope"); 645 CX_TEST_ASSERT(l1->scope == WEBDAV_LOCK_SHARED);
687 UCX_TEST_ASSERT(l1->owner, "l1: owner is NULL"); 646 CX_TEST_ASSERT(l1->owner);
688 UCX_TEST_ASSERT(!strcmp((char*)l1->owner->content, "User"), "l1: wrong owner"); 647 CX_TEST_ASSERT(!strcmp((char*)l1->owner->content, "User"));
689 648
690 UCX_TEST_END 649 }
691 650
692 pool_destroy(sn->pool); 651 pool_destroy(sn->pool);
693 } 652 }
694 653
695 UCX_TEST(test_rqbody2buffer) { 654 CX_TEST(test_rqbody2buffer) {
696 Session *sn; 655 Session *sn;
697 Request *rq; 656 Request *rq;
698 657
699 UCX_TEST_BEGIN; 658 CX_TEST_DO {
700 // 659 //
701 // TEST 1 660 // TEST 1
702 sn = testutil_session(); 661 sn = testutil_session();
703 rq = testutil_request(sn->pool, "PUT", "/"); 662 rq = testutil_request(sn->pool, "PUT", "/");
704 testutil_request_body(sn, rq, "Hello World!", 12); 663 testutil_request_body(sn, rq, "Hello World!", 12);
705 664
706 CxBuffer b1; 665 CxBuffer b1;
707 rqbody2buffer(sn, rq, &b1); 666 rqbody2buffer(sn, rq, &b1);
708 UCX_TEST_ASSERT(b1.size == 12, "b1: wrong size"); 667 CX_TEST_ASSERT(b1.size == 12);
709 UCX_TEST_ASSERT(!memcmp(b1.space,"Hello World!",12), "b1: wrong content"); 668 CX_TEST_ASSERT(!memcmp(b1.space,"Hello World!",12));
710 669
711 cxBufferDestroy(&b1); 670 cxBufferDestroy(&b1);
712 testutil_destroy_session(sn); 671 testutil_destroy_session(sn);
713 672
714 // 673 //
715 // TEST 2 674 // TEST 2
716 size_t len1 = 25000; 675 size_t len1 = 25000;
717 unsigned char *body1 = malloc(len1); 676 unsigned char *body1 = malloc(len1);
718 for(int i=0;i<len1;i++) { 677 for(int i=0;i<len1;i++) {
719 body1[i] = i; 678 body1[i] = i;
720 } 679 }
721 sn = testutil_session(); 680 sn = testutil_session();
722 rq = testutil_request(sn->pool, "PUT", "/"); 681 rq = testutil_request(sn->pool, "PUT", "/");
723 testutil_request_body(sn, rq, (char*)body1, len1); 682 testutil_request_body(sn, rq, (char*)body1, len1);
724 683
725 CxBuffer b2; 684 CxBuffer b2;
726 rqbody2buffer(sn, rq, &b2); 685 rqbody2buffer(sn, rq, &b2);
727 UCX_TEST_ASSERT(b2.size == len1, "b2: wrong size"); 686 CX_TEST_ASSERT(b2.size == len1);
728 UCX_TEST_ASSERT(!memcmp(b2.space, body1, len1), "b2: wrong content"); 687 CX_TEST_ASSERT(!memcmp(b2.space, body1, len1));
729 688
730 cxBufferDestroy(&b2); 689 cxBufferDestroy(&b2);
731 testutil_destroy_session(sn); 690 testutil_destroy_session(sn);
732 691
733 UCX_TEST_END; 692 }
734 } 693 }
735 694
736 UCX_TEST(test_webdav_plist_iterator) { 695 CX_TEST(test_webdav_plist_iterator) {
737 Session *sn; 696 Session *sn;
738 Request *rq; 697 Request *rq;
739 WebdavPropfindRequest *propfind; 698 WebdavPropfindRequest *propfind;
740 699
741 UCX_TEST_BEGIN; 700 CX_TEST_DO {
742 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); 701 CX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1));
743 702
744 WebdavPList *properties = propfind->properties; 703 WebdavPList *properties = propfind->properties;
745 size_t count = 0; 704 size_t count = 0;
746 705
747 WebdavPListIterator i = webdav_plist_iterator(&properties); 706 WebdavPListIterator i = webdav_plist_iterator(&properties);
748 WebdavPList *cur; 707 WebdavPList *cur;
749 while(webdav_plist_iterator_next(&i, &cur)) { 708 while(webdav_plist_iterator_next(&i, &cur)) {
750 switch(i.index) { 709 switch(i.index) {
751 case 0: { 710 case 0: {
752 UCX_TEST_ASSERT(!strcmp(cur->property->name, "displayname"), "wrong property 1"); 711 CX_TEST_ASSERT(!strcmp(cur->property->name, "displayname"));
753 break; 712 break;
713 }
714 case 1: {
715 CX_TEST_ASSERT(!strcmp(cur->property->name, "getcontentlength"));
716 break;
717 }
718 case 2: {
719 CX_TEST_ASSERT(!strcmp(cur->property->name, "getcontenttype"));
720 break;
721 }
722 case 3: {
723 CX_TEST_ASSERT(!strcmp(cur->property->name, "getlastmodified"));
724 break;
725 }
726 case 4: {
727 CX_TEST_ASSERT(!strcmp(cur->property->name, "resourcetype"));
728 break;
729 }
730 case 5: {
731 CX_TEST_ASSERT(!strcmp(cur->property->name, "getetag"));
732 break;
733 }
754 } 734 }
755 case 1: { 735 count++;
756 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getcontentlength"), "wrong property 2"); 736 }
757 break; 737
758 } 738 CX_TEST_ASSERT(count == propfind->propcount);
759 case 2: { 739
760 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getcontenttype"), "wrong property 3"); 740
761 break; 741 }
762 }
763 case 3: {
764 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getlastmodified"), "wrong property 4");
765 break;
766 }
767 case 4: {
768 UCX_TEST_ASSERT(!strcmp(cur->property->name, "resourcetype"), "wrong property 5");
769 break;
770 }
771 case 5: {
772 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getetag"), "wrong property 6");
773 break;
774 }
775 }
776 count++;
777 }
778
779 UCX_TEST_ASSERT(count == propfind->propcount, "wrong count");
780
781
782 UCX_TEST_END;
783 testutil_destroy_session(sn); 742 testutil_destroy_session(sn);
784 } 743 }
785 744
786 UCX_TEST(test_webdav_plist_iterator_remove_current) { 745 CX_TEST(test_webdav_plist_iterator_remove_current) {
787 Session *sn; 746 Session *sn;
788 Request *rq; 747 Request *rq;
789 WebdavPropfindRequest *propfind; 748 WebdavPropfindRequest *propfind;
790 749
791 UCX_TEST_BEGIN; 750 CX_TEST_DO {
792 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); 751 CX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1));
793 752
794 WebdavPList *properties1 = webdav_plist_clone(sn->pool, propfind->properties); 753 WebdavPList *properties1 = webdav_plist_clone(sn->pool, propfind->properties);
795 WebdavPList *properties2 = webdav_plist_clone(sn->pool, propfind->properties); 754 WebdavPList *properties2 = webdav_plist_clone(sn->pool, propfind->properties);
796 WebdavPList *properties3 = webdav_plist_clone(sn->pool, propfind->properties); 755 WebdavPList *properties3 = webdav_plist_clone(sn->pool, propfind->properties);
797 WebdavPList *properties4 = webdav_plist_clone(sn->pool, propfind->properties); 756 WebdavPList *properties4 = webdav_plist_clone(sn->pool, propfind->properties);
798 757
799 WebdavPListIterator i; 758 WebdavPListIterator i;
800 WebdavPList *cur; 759 WebdavPList *cur;
801 760
802 // test removal of first element 761 // test removal of first element
803 i = webdav_plist_iterator(&properties1); 762 i = webdav_plist_iterator(&properties1);
804 while(webdav_plist_iterator_next(&i, &cur)) { 763 while(webdav_plist_iterator_next(&i, &cur)) {
805 if(i.index == 0) { 764 if(i.index == 0) {
765 webdav_plist_iterator_remove_current(&i);
766 }
767 }
768
769 CX_TEST_ASSERT(!properties1->prev);
770 CX_TEST_ASSERT(!strcmp(properties1->property->name, "getcontentlength"));
771 CX_TEST_ASSERT(!strcmp(properties1->next->property->name, "getcontenttype"));
772 CX_TEST_ASSERT(properties1->next->prev == properties1);
773
774 // test removal of second element
775 i = webdav_plist_iterator(&properties2);
776 while(webdav_plist_iterator_next(&i, &cur)) {
777 if(i.index == 1) {
778 webdav_plist_iterator_remove_current(&i);
779 }
780 }
781
782 CX_TEST_ASSERT(!strcmp(properties2->next->property->name, "getcontenttype"));
783 CX_TEST_ASSERT(properties2->next->prev == properties2);
784 CX_TEST_ASSERT(webdav_plist_size(properties2) == 5);
785
786 // remove last element
787 i = webdav_plist_iterator(&properties3);
788 while(webdav_plist_iterator_next(&i, &cur)) {
789 if(i.index == 5) {
790 webdav_plist_iterator_remove_current(&i);
791 }
792 }
793
794 CX_TEST_ASSERT(webdav_plist_size(properties3) == 5);
795 CX_TEST_ASSERT(!strcmp(properties3->next->next->next->next->property->name, "resourcetype"));
796
797 // remove all elements
798 i = webdav_plist_iterator(&properties4);
799 while(webdav_plist_iterator_next(&i, &cur)) {
806 webdav_plist_iterator_remove_current(&i); 800 webdav_plist_iterator_remove_current(&i);
807 } 801 switch(i.index) {
808 } 802 case 0: {
809 803 CX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontentlength"));
810 UCX_TEST_ASSERT(!properties1->prev, "test1: prev not cleared"); 804 CX_TEST_ASSERT(properties4->prev == NULL);
811 UCX_TEST_ASSERT(!strcmp(properties1->property->name, "getcontentlength"), "test1: wrong property"); 805 break;
812 UCX_TEST_ASSERT(!strcmp(properties1->next->property->name, "getcontenttype"), "test1: wrong property 2"); 806 }
813 UCX_TEST_ASSERT(properties1->next->prev == properties1, "test1: wrong link"); 807 case 1: {
814 808 CX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontenttype"));
815 // test removal of second element 809 CX_TEST_ASSERT(properties4->prev == NULL);
816 i = webdav_plist_iterator(&properties2); 810 break;
817 while(webdav_plist_iterator_next(&i, &cur)) { 811 }
818 if(i.index == 1) { 812 case 2: {
819 webdav_plist_iterator_remove_current(&i); 813 CX_TEST_ASSERT(!strcmp(properties4->property->name, "getlastmodified"));
820 } 814 CX_TEST_ASSERT(properties4->prev == NULL);
821 } 815 break;
822 816 }
823 UCX_TEST_ASSERT(!strcmp(properties2->next->property->name, "getcontenttype"), "test2: wrong property"); 817 case 3: {
824 UCX_TEST_ASSERT(properties2->next->prev == properties2, "test2: wrong link"); 818 CX_TEST_ASSERT(!strcmp(properties4->property->name, "resourcetype"));
825 UCX_TEST_ASSERT(webdav_plist_size(properties2) == 5, "test2: wrong size"); 819 CX_TEST_ASSERT(properties4->prev == NULL);
826 820 break;
827 // remove last element 821 }
828 i = webdav_plist_iterator(&properties3); 822 case 4: {
829 while(webdav_plist_iterator_next(&i, &cur)) { 823 CX_TEST_ASSERT(!strcmp(properties4->property->name, "getetag"));
830 if(i.index == 5) { 824 CX_TEST_ASSERT(properties4->prev == NULL);
831 webdav_plist_iterator_remove_current(&i); 825 break;
832 } 826 }
833 } 827 default: {
834 828 CX_TEST_ASSERT(i.index <= 5);
835 UCX_TEST_ASSERT(webdav_plist_size(properties3) == 5, "test3: wrong size"); 829 }
836 UCX_TEST_ASSERT(!strcmp(properties3->next->next->next->next->property->name, "resourcetype"), "test2: wrong property");
837
838 // remove all elements
839 i = webdav_plist_iterator(&properties4);
840 while(webdav_plist_iterator_next(&i, &cur)) {
841 webdav_plist_iterator_remove_current(&i);
842 switch(i.index) {
843 case 0: {
844 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontentlength"), "test4: wrong property 2");
845 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (0)");
846 break;
847 } 830 }
848 case 1: { 831 }
849 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontenttype"), "test4: wrong property 3"); 832
850 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (1)"); 833 CX_TEST_ASSERT(properties4 == NULL);
851 break; 834
852 } 835 }
853 case 2: {
854 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getlastmodified"), "test4: wrong property 4");
855 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (2)");
856 break;
857 }
858 case 3: {
859 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "resourcetype"), "test4: wrong property 5");
860 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (3)");
861 break;
862 }
863 case 4: {
864 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getetag"), "test4: wrong property 6");
865 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (4)");
866 break;
867 }
868 default: {
869 UCX_TEST_ASSERT(i.index <= 5, "fail");
870 }
871 }
872 }
873
874 UCX_TEST_ASSERT(properties4 == NULL, "test4: list not NULL");
875
876 UCX_TEST_END;
877 testutil_destroy_session(sn); 836 testutil_destroy_session(sn);
878 } 837 }
879 838
880 UCX_TEST(test_msresponse_addproperty) { 839 CX_TEST(test_msresponse_addproperty) {
881 Session *sn; 840 Session *sn;
882 Request *rq; 841 Request *rq;
883 842
884 UCX_TEST_BEGIN; 843 CX_TEST_DO {
885 844
886 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); 845 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
887 UCX_TEST_ASSERT(op, "init failed"); 846 CX_TEST_ASSERT(op);
888 UCX_TEST_ASSERT(op->response, "no response"); 847 CX_TEST_ASSERT(op->response);
889 848
890 Multistatus *ms = (Multistatus*)op->response; 849 Multistatus *ms = (Multistatus*)op->response;
891 MSResponse *r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/"); 850 MSResponse *r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/");
892 851
893 WebdavProperty p1; 852 WebdavProperty p1;
894 WebdavProperty p[16]; 853 WebdavProperty p[16];
895 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"}; 854 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"};
896 855
897 WSNamespace ns1; 856 WSNamespace ns1;
898 ZERO(&ns1, sizeof(WSNamespace)); 857 ZERO(&ns1, sizeof(WSNamespace));
899 WSNamespace ns2; 858 WSNamespace ns2;
900 ZERO(&ns2, sizeof(WSNamespace)); 859 ZERO(&ns2, sizeof(WSNamespace));
901 ns1.prefix = (xmlChar*)"x1"; 860 ns1.prefix = (xmlChar*)"x1";
902 ns1.href = (xmlChar*)"http://example.com/test/"; 861 ns1.href = (xmlChar*)"http://example.com/test/";
903 ns2.prefix = (xmlChar*)"x2"; 862 ns2.prefix = (xmlChar*)"x2";
904 ns2.href = (xmlChar*)"http://example.com/test/"; 863 ns2.href = (xmlChar*)"http://example.com/test/";
905 864
906 WebdavProperty dp1; 865 WebdavProperty dp1;
907 ZERO(&dp1, sizeof(WebdavProperty)); 866 ZERO(&dp1, sizeof(WebdavProperty));
908 dp1.name = "dup"; 867 dp1.name = "dup";
909 dp1.namespace = &ns1; 868 dp1.namespace = &ns1;
910 dp1.value.text.str = "Hello"; 869 dp1.value.text.str = "Hello";
911 dp1.value.text.length = 5; 870 dp1.value.text.length = 5;
912 dp1.vtype = WS_VALUE_TEXT; 871 dp1.vtype = WS_VALUE_TEXT;
913 872
914 WebdavProperty dp2; 873 WebdavProperty dp2;
915 ZERO(&dp2, sizeof(WebdavProperty)); 874 ZERO(&dp2, sizeof(WebdavProperty));
916 dp2.name = "dup"; 875 dp2.name = "dup";
917 dp2.namespace = &ns1; 876 dp2.namespace = &ns1;
918 dp2.value.text.str = "Hello"; 877 dp2.value.text.str = "Hello";
919 dp2.value.text.length = 5; 878 dp2.value.text.length = 5;
920 dp2.vtype = WS_VALUE_TEXT; 879 dp2.vtype = WS_VALUE_TEXT;
921 880
922 WebdavProperty dp3; 881 WebdavProperty dp3;
923 ZERO(&dp3, sizeof(WebdavProperty)); 882 ZERO(&dp3, sizeof(WebdavProperty));
924 dp3.name = "dup"; 883 dp3.name = "dup";
925 dp3.namespace = &ns2; 884 dp3.namespace = &ns2;
926 dp3.value.text.str = "Hello"; 885 dp3.value.text.str = "Hello";
927 dp3.value.text.length = 5; 886 dp3.value.text.length = 5;
928 dp3.vtype = WS_VALUE_TEXT; 887 dp3.vtype = WS_VALUE_TEXT;
929 888
930 // init test data 889 // init test data
931 p1.namespace = webdav_dav_namespace(); 890 p1.namespace = webdav_dav_namespace();
932 p1.lang = NULL; 891 p1.lang = NULL;
933 p1.name = "test1"; 892 p1.name = "test1";
934 p1.value.data = (WSXmlData){ NULL, NULL, 0}; 893 p1.value.data = (WSXmlData){ NULL, NULL, 0};
935 p1.vtype = 0; 894 p1.vtype = 0;
936 895
937 for(int i=0;i<8;i++) { 896 for(int i=0;i<8;i++) {
938 p[i].namespace = webdav_dav_namespace(); 897 p[i].namespace = webdav_dav_namespace();
939 p[i].name = names[i]; 898 p[i].name = names[i];
940 p[i].lang = NULL; 899 p[i].lang = NULL;
941 p[i].value.node = NULL; 900 p[i].value.node = NULL;
942 p[1].vtype = 0; 901 p[1].vtype = 0;
943 } 902 }
944 903
945 UCX_TEST_ASSERT(!r->plist_begin && !r->plist_end, "plist not empty"); 904 CX_TEST_ASSERT(!r->plist_begin && !r->plist_end);
946 905
947 r->resource.addproperty((WebdavResource*)r, &p1, 200); 906 r->resource.addproperty((WebdavResource*)r, &p1, 200);
948 UCX_TEST_ASSERT(r->plist_begin, "!plist_begin"); 907 CX_TEST_ASSERT(r->plist_begin);
949 UCX_TEST_ASSERT(r->plist_begin == r->plist_end, "plist begin != end"); 908 CX_TEST_ASSERT(r->plist_begin == r->plist_end);
950 909
951 r->resource.addproperty((WebdavResource*)r, &p[0], 404); 910 r->resource.addproperty((WebdavResource*)r, &p[0], 404);
952 r->resource.addproperty((WebdavResource*)r, &p[1], 404); 911 r->resource.addproperty((WebdavResource*)r, &p[1], 404);
953 r->resource.addproperty((WebdavResource*)r, &p[2], 403); 912 r->resource.addproperty((WebdavResource*)r, &p[2], 403);
954 r->resource.addproperty((WebdavResource*)r, &p[3], 403); 913 r->resource.addproperty((WebdavResource*)r, &p[3], 403);
955 r->resource.addproperty((WebdavResource*)r, &p[4], 403); 914 r->resource.addproperty((WebdavResource*)r, &p[4], 403);
956 r->resource.addproperty((WebdavResource*)r, &p[5], 403); 915 r->resource.addproperty((WebdavResource*)r, &p[5], 403);
957 r->resource.addproperty((WebdavResource*)r, &p[6], 500); 916 r->resource.addproperty((WebdavResource*)r, &p[6], 500);
958 917
959 UCX_TEST_ASSERT(r->plist_begin == r->plist_end, "plist begin != end"); 918 CX_TEST_ASSERT(r->plist_begin == r->plist_end);
960 919
961 UCX_TEST_ASSERT(r->errors, "no prop errors"); 920 CX_TEST_ASSERT(r->errors);
962 UCX_TEST_ASSERT(r->errors->next, "no second error code"); 921 CX_TEST_ASSERT(r->errors->next);
963 UCX_TEST_ASSERT(r->errors->next->next, "no third error code"); 922 CX_TEST_ASSERT(r->errors->next->next);
964 UCX_TEST_ASSERT(!r->errors->next->next->next, "too many error codes"); 923 CX_TEST_ASSERT(!r->errors->next->next->next);
965 924
966 UCX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 2, "404 list size != 2"); 925 CX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 2);
967 UCX_TEST_ASSERT(webdav_plist_size(r->errors->next->begin) == 4, "403 list size != 4"); 926 CX_TEST_ASSERT(webdav_plist_size(r->errors->next->begin) == 4);
968 UCX_TEST_ASSERT(webdav_plist_size(r->errors->next->next->begin) == 1, "500 list size != 1"); 927 CX_TEST_ASSERT(webdav_plist_size(r->errors->next->next->begin) == 1);
969 928
970 // new resource for prop duplication tests 929 // new resource for prop duplication tests
971 r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test"); 930 r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test");
972 UCX_TEST_ASSERT(r, "cannot create second response"); 931 CX_TEST_ASSERT(r);
973 932
974 r->resource.addproperty((WebdavResource*)r, &dp1, 200); 933 r->resource.addproperty((WebdavResource*)r, &dp1, 200);
975 UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed"); 934 CX_TEST_ASSERT(r->plist_begin);
976 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: list size not 1"); 935 CX_TEST_ASSERT(!r->plist_begin->next);
977 936
978 r->resource.addproperty((WebdavResource*)r, &dp2, 200); 937 r->resource.addproperty((WebdavResource*)r, &dp2, 200);
979 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 should not work"); 938 CX_TEST_ASSERT(!r->plist_begin->next);
980 939
981 r->resource.addproperty((WebdavResource*)r, &dp2, 404); 940 r->resource.addproperty((WebdavResource*)r, &dp2, 404);
982 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 with different status should not work (1)"); 941 CX_TEST_ASSERT(!r->plist_begin->next);
983 if(r->errors) { 942 if(r->errors) {
984 UCX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 0, "dp1: error list not empty"); 943 CX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 0);
985 } 944 }
986 945
987 r->resource.addproperty((WebdavResource*)r, &dp3, 200); 946 r->resource.addproperty((WebdavResource*)r, &dp3, 200);
988 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp3 should not work"); 947 CX_TEST_ASSERT(!r->plist_begin->next);
989 948
990 UCX_TEST_END; 949 }
991 } 950 }
992 951
993 UCX_TEST(test_webdav_propfind_init) { 952 CX_TEST(test_webdav_propfind_init) {
994 reset_backends(); 953 reset_backends();
995 954
996 Session *sn; 955 Session *sn;
997 Request *rq; 956 Request *rq;
998 WebdavPropfindRequest *propfind; 957 WebdavPropfindRequest *propfind;
999 UCX_TEST_BEGIN; 958 CX_TEST_DO {
1000 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); 959 CX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1));
1001 960
1002 WebdavPropfindRequestList *requests = NULL; 961 WebdavPropfindRequestList *requests = NULL;
1003 int err = webdav_propfind_init(&backend1, propfind, "/", "/", &requests); 962 int err = webdav_propfind_init(&backend1, propfind, "/", "/", &requests);
1004 963
1005 UCX_TEST_ASSERT(!err, "webdav_propfind_init failed"); 964 CX_TEST_ASSERT(!err);
1006 UCX_TEST_ASSERT(requests, "request list is empty"); 965 CX_TEST_ASSERT(requests);
1007 UCX_TEST_ASSERT(cx_linked_list_size(requests, offsetof(WebdavPropfindRequestList, next)), "request list has wrong size"); 966 CX_TEST_ASSERT(cx_linked_list_size(requests, offsetof(WebdavPropfindRequestList, next)));
1008 967
1009 WebdavPropfindRequest *p1 = requests->propfind; 968 WebdavPropfindRequest *p1 = requests->propfind;
1010 WebdavPropfindRequest *p2 = requests->next->propfind; 969 WebdavPropfindRequest *p2 = requests->next->propfind;
1011 970
1012 // backend1 removes the first property from the plist 971 // backend1 removes the first property from the plist
1013 // backend2 should have one property less 972 // backend2 should have one property less
1014 973
1015 UCX_TEST_ASSERT(p1 && p2, "missing requests objects"); 974 CX_TEST_ASSERT(p1 && p2);
1016 UCX_TEST_ASSERT(p1 != p2, "request objects equal"); 975 CX_TEST_ASSERT(p1 != p2);
1017 UCX_TEST_ASSERT(p1->properties != p2->properties, "plists equal"); 976 CX_TEST_ASSERT(p1->properties != p2->properties);
1018 UCX_TEST_ASSERT(p1->propcount == p2->propcount + 1, "first property not removed"); 977 CX_TEST_ASSERT(p1->propcount == p2->propcount + 1);
1019 978
1020 UCX_TEST_ASSERT(backend1_init_called == 1, "backend1 init not called"); 979 CX_TEST_ASSERT(backend1_init_called == 1);
1021 UCX_TEST_ASSERT(backend2_init_called == 1, "backend2 init not called"); 980 CX_TEST_ASSERT(backend2_init_called == 1);
1022 981
1023 UCX_TEST_END; 982 }
1024 983
1025 pool_destroy(sn->pool); 984 pool_destroy(sn->pool);
1026 } 985 }
1027 986
1028 UCX_TEST(test_webdav_op_propfind_begin) { 987 CX_TEST(test_webdav_op_propfind_begin) {
1029 reset_backends(); 988 reset_backends();
1030 989
1031 Session *sn; 990 Session *sn;
1032 Request *rq; 991 Request *rq;
1033 992
1034 UCX_TEST_BEGIN; 993 CX_TEST_DO {
1035 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); 994 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
1036 UCX_TEST_ASSERT(op, "WebdavOperation not created"); 995 CX_TEST_ASSERT(op);
1037 996
1038 int err = webdav_op_propfind_begin(op, "/", NULL, NULL); 997 int err = webdav_op_propfind_begin(op, "/", NULL, NULL);
1039 UCX_TEST_ASSERT(err == 0, "err not 0"); 998 CX_TEST_ASSERT(err == 0);
1040 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called"); 999 CX_TEST_ASSERT(backend1_propfind_do_count == 1);
1041 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend2 propfind_do not called"); 1000 CX_TEST_ASSERT(backend2_propfind_do_count == 1);
1042 1001
1043 1002 }
1044 UCX_TEST_END;
1045 testutil_destroy_session(sn); 1003 testutil_destroy_session(sn);
1046 } 1004 }
1047 1005
1048 UCX_TEST(test_webdav_op_propfind_children) { 1006 CX_TEST(test_webdav_op_propfind_children) {
1049 reset_backends(); 1007 reset_backends();
1050 1008
1051 Session *sn; 1009 Session *sn;
1052 Request *rq; 1010 Request *rq;
1053 1011
1054 UCX_TEST_BEGIN; 1012 CX_TEST_DO {
1055 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); 1013 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
1056 UCX_TEST_ASSERT(op, "WebdavOperation not created"); 1014 CX_TEST_ASSERT(op);
1057 1015
1058 int err = webdav_op_propfind_begin(op, "/", NULL, NULL); 1016 int err = webdav_op_propfind_begin(op, "/", NULL, NULL);
1059 UCX_TEST_ASSERT(err == 0, "propfind_begin error"); 1017 CX_TEST_ASSERT(err == 0);
1060 1018
1061 // create test vfs with some files (code from test_vfs_readdir) 1019 // create test vfs with some files (code from test_vfs_readdir)
1062 rq->vfs = testvfs_create(sn); 1020 rq->vfs = testvfs_create(sn);
1063 VFSContext *vfs = vfs_request_context(sn, rq); 1021 VFSContext *vfs = vfs_request_context(sn, rq);
1064 UCX_TEST_ASSERT(vfs, "no vfs"); 1022 CX_TEST_ASSERT(vfs);
1065 1023
1066 err = vfs_mkdir(vfs, "/dir"); 1024 err = vfs_mkdir(vfs, "/dir");
1067 UCX_TEST_ASSERT(err == 0, "error not 0"); 1025 CX_TEST_ASSERT(err == 0);
1068 1026
1069 // add some test file to /dir 1027 // add some test file to /dir
1070 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT), "creation of file1 failed"); 1028 CX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT));
1071 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT), "creation of file2 failed"); 1029 CX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT));
1072 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT), "creation of file3 failed"); 1030 CX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT));
1073 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed"); 1031 CX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT));
1074 1032
1075 VFSDir *dir = vfs_opendir(vfs, "/dir"); 1033 VFSDir *dir = vfs_opendir(vfs, "/dir");
1076 UCX_TEST_ASSERT(dir, "dir not opened"); 1034 CX_TEST_ASSERT(dir);
1077 1035
1078 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called"); 1036 CX_TEST_ASSERT(backend1_propfind_do_count == 1);
1079 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend1 propfind_do not called") 1037 CX_TEST_ASSERT(backend2_propfind_do_count == 1);
1080 1038
1081 // propfind for all children 1039 // propfind for all children
1082 err = webdav_op_propfind_children(op, vfs, "/", "/dir"); 1040 err = webdav_op_propfind_children(op, vfs, "/", "/dir");
1083 UCX_TEST_ASSERT(err == 0, "webdav_op_propfind_children failed"); 1041 CX_TEST_ASSERT(err == 0);
1084 1042
1085 // 1 dir + 4 children 1043 // 1 dir + 4 children
1086 UCX_TEST_ASSERT(backend1_propfind_do_count == 5, "backend1 propfind_do wrong count"); 1044 CX_TEST_ASSERT(backend1_propfind_do_count == 5);
1087 UCX_TEST_ASSERT(backend2_propfind_do_count == 5, "backend2 propfind_do wrong count"); 1045 CX_TEST_ASSERT(backend2_propfind_do_count == 5);
1088 1046
1089 UCX_TEST_END; 1047 }
1090 testutil_destroy_session(sn); 1048 testutil_destroy_session(sn);
1091 } 1049 }
1092 1050
1093 void init_test_webdav_method( 1051 void init_test_webdav_method(
1094 Session **out_sn, 1052 Session **out_sn,
1123 *out_rq = rq; 1081 *out_rq = rq;
1124 *out_st = st; 1082 *out_st = st;
1125 *out_pb = pb; 1083 *out_pb = pb;
1126 } 1084 }
1127 1085
1128 UCX_TEST(test_webdav_propfind) { 1086 CX_TEST(test_webdav_propfind) {
1129 Session *sn; 1087 Session *sn;
1130 Request *rq; 1088 Request *rq;
1131 TestIOStream *st; 1089 TestIOStream *st;
1132 pblock *pb; 1090 pblock *pb;
1133 1091
1134 UCX_TEST_BEGIN; 1092 CX_TEST_DO {
1135 1093
1136 int ret; 1094 int ret;
1137 // Test 1 1095 // Test 1
1138 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND1); 1096 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND1);
1139 1097
1140 ret = webdav_propfind(pb, sn, rq); 1098 ret = webdav_propfind(pb, sn, rq);
1141 1099
1142 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); 1100 CX_TEST_ASSERT(ret == REQ_PROCEED);
1143 1101
1144 xmlDoc *doc = xmlReadMemory( 1102 xmlDoc *doc = xmlReadMemory(
1145 st->buf->space, st->buf->size, NULL, NULL, 0); 1103 st->buf->space, st->buf->size, NULL, NULL, 0);
1146 UCX_TEST_ASSERT(doc, "propfind1: response is not valid xml"); 1104 CX_TEST_ASSERT(doc);
1147 1105
1148 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); 1106 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
1149 1107
1150 testutil_destroy_session(sn); 1108 testutil_destroy_session(sn);
1151 xmlFreeDoc(doc); 1109 xmlFreeDoc(doc);
1152 testutil_iostream_destroy(st); 1110 testutil_iostream_destroy(st);
1153 1111
1154 // Test2 1112 // Test2
1155 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND2); 1113 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND2);
1156 1114
1157 ret = webdav_propfind(pb, sn, rq); 1115 ret = webdav_propfind(pb, sn, rq);
1158 1116
1159 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); 1117 CX_TEST_ASSERT(ret == REQ_PROCEED);
1160 1118
1161 xmlDoc *doc2 = xmlReadMemory( 1119 xmlDoc *doc2 = xmlReadMemory(
1162 st->buf->space, st->buf->size, NULL, NULL, 0); 1120 st->buf->space, st->buf->size, NULL, NULL, 0);
1163 UCX_TEST_ASSERT(doc, "propfind2: response is not valid xml"); 1121 CX_TEST_ASSERT(doc);
1164 1122
1165 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); 1123 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
1166 1124
1167 testutil_destroy_session(sn); 1125 testutil_destroy_session(sn);
1168 xmlFreeDoc(doc2); 1126 xmlFreeDoc(doc2);
1169 testutil_iostream_destroy(st); 1127 testutil_iostream_destroy(st);
1170 1128
1171 UCX_TEST_END; 1129 }
1172 1130
1173 } 1131 }
1174 1132
1175 /* ------------------------------------------------------------------------- 1133 /* -------------------------------------------------------------------------
1176 * 1134 *
1242 proppatch, 1200 proppatch,
1243 response); 1201 response);
1244 } 1202 }
1245 1203
1246 1204
1247 UCX_TEST(test_proppatch_msresponse) { 1205 CX_TEST(test_proppatch_msresponse) {
1248 Session *sn; 1206 Session *sn;
1249 Request *rq; 1207 Request *rq;
1250 WebdavOperation *op; 1208 WebdavOperation *op;
1251 1209
1252 Multistatus *ms; 1210 Multistatus *ms;
1260 p[i].lang = NULL; 1218 p[i].lang = NULL;
1261 p[i].value.node = NULL; 1219 p[i].value.node = NULL;
1262 p[i].vtype = 0; 1220 p[i].vtype = 0;
1263 } 1221 }
1264 1222
1265 UCX_TEST_BEGIN; 1223 CX_TEST_DO {
1266 1224
1267 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2); 1225 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
1268 UCX_TEST_ASSERT(op, "failed to create proppatch operation"); 1226 CX_TEST_ASSERT(op);
1269 1227
1270 ms = (Multistatus*)op->response; 1228 ms = (Multistatus*)op->response;
1271 ms->proppatch = TRUE; 1229 ms->proppatch = TRUE;
1272 res = ms->response.addresource(&ms->response, "/"); 1230 res = ms->response.addresource(&ms->response, "/");
1273 UCX_TEST_ASSERT(res, "cannot create resource 1"); 1231 CX_TEST_ASSERT(res);
1274 1232
1275 UCX_TEST_ASSERT(!res->addproperty(res, &p[0], 200), "addproperty 1 failed"); 1233 CX_TEST_ASSERT(!res->addproperty(res, &p[0], 200));
1276 UCX_TEST_ASSERT(!res->addproperty(res, &p[1], 200), "addproperty 2 failed"); 1234 CX_TEST_ASSERT(!res->addproperty(res, &p[1], 200));
1277 UCX_TEST_ASSERT(!res->addproperty(res, &p[2], 200), "addproperty 3 failed"); 1235 CX_TEST_ASSERT(!res->addproperty(res, &p[2], 200));
1278 UCX_TEST_ASSERT(!res->addproperty(res, &p[3], 200), "addproperty 4 failed"); 1236 CX_TEST_ASSERT(!res->addproperty(res, &p[3], 200));
1279 1237
1280 UCX_TEST_ASSERT(!res->close(res), "close failed"); 1238 CX_TEST_ASSERT(!res->close(res));
1281 1239
1282 MSResponse *msres = (MSResponse*)res; 1240 MSResponse *msres = (MSResponse*)res;
1283 UCX_TEST_ASSERT(!msres->errors, "error list not NULL"); 1241 CX_TEST_ASSERT(!msres->errors);
1284 UCX_TEST_ASSERT(msres->plist_begin, "elm1 missing"); 1242 CX_TEST_ASSERT(msres->plist_begin);
1285 UCX_TEST_ASSERT(msres->plist_begin->next, "elm2 missing"); 1243 CX_TEST_ASSERT(msres->plist_begin->next);
1286 UCX_TEST_ASSERT(msres->plist_begin->next->next, "elm3 missing"); 1244 CX_TEST_ASSERT(msres->plist_begin->next->next);
1287 UCX_TEST_ASSERT(msres->plist_begin->next->next->next, "elm4 missing"); 1245 CX_TEST_ASSERT(msres->plist_begin->next->next->next);
1288 UCX_TEST_ASSERT(!msres->plist_begin->next->next->next->next, "count != 4"); 1246 CX_TEST_ASSERT(!msres->plist_begin->next->next->next->next);
1289 1247
1290 UCX_TEST_END; 1248 }
1291 testutil_destroy_session(sn); 1249 testutil_destroy_session(sn);
1292 } 1250 }
1293 1251
1294 UCX_TEST(test_msresponse_addproperty_with_errors) { 1252 CX_TEST(test_msresponse_addproperty_with_errors) {
1295 Session *sn; 1253 Session *sn;
1296 Request *rq; 1254 Request *rq;
1297 WebdavOperation *op; 1255 WebdavOperation *op;
1298 1256
1299 Multistatus *ms; 1257 Multistatus *ms;
1307 p[i].lang = NULL; 1265 p[i].lang = NULL;
1308 p[i].value.node = NULL; 1266 p[i].value.node = NULL;
1309 p[i].vtype = 0; 1267 p[i].vtype = 0;
1310 } 1268 }
1311 1269
1312 UCX_TEST_BEGIN; 1270 CX_TEST_DO {
1313 1271
1314 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2); 1272 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
1315 UCX_TEST_ASSERT(op, "failed to create proppatch operation"); 1273 CX_TEST_ASSERT(op);
1316 1274
1317 ms = (Multistatus*)op->response; 1275 ms = (Multistatus*)op->response;
1318 ms->proppatch = TRUE; 1276 ms->proppatch = TRUE;
1319 res = ms->response.addresource(&ms->response, "/"); 1277 res = ms->response.addresource(&ms->response, "/");
1320 UCX_TEST_ASSERT(res, "cannot create resource 1"); 1278 CX_TEST_ASSERT(res);
1321 1279
1322 UCX_TEST_ASSERT(!res->addproperty(res, &p[0], 200), "addproperty 1 failed"); 1280 CX_TEST_ASSERT(!res->addproperty(res, &p[0], 200));
1323 UCX_TEST_ASSERT(!res->addproperty(res, &p[1], 200), "addproperty 2 failed"); 1281 CX_TEST_ASSERT(!res->addproperty(res, &p[1], 200));
1324 UCX_TEST_ASSERT(!res->addproperty(res, &p[2], 409), "addproperty 3 failed"); 1282 CX_TEST_ASSERT(!res->addproperty(res, &p[2], 409));
1325 UCX_TEST_ASSERT(!res->addproperty(res, &p[3], 200), "addproperty 4 failed"); 1283 CX_TEST_ASSERT(!res->addproperty(res, &p[3], 200));
1326 1284
1327 UCX_TEST_ASSERT(!res->close(res), "close failed"); 1285 CX_TEST_ASSERT(!res->close(res));
1328 1286
1329 // all properties should have an error status code now 1287 // all properties should have an error status code now
1330 // 1 x 409, 3 x 424 1288 // 1 x 409, 3 x 424
1331 1289
1332 MSResponse *msres = (MSResponse*)res; 1290 MSResponse *msres = (MSResponse*)res;
1333 1291
1334 UCX_TEST_ASSERT(!msres->plist_begin, "plist not NULL"); 1292 CX_TEST_ASSERT(!msres->plist_begin);
1335 UCX_TEST_ASSERT(msres->errors, "error list is NULL"); 1293 CX_TEST_ASSERT(msres->errors);
1336 UCX_TEST_ASSERT(msres->errors->next, "second error list is missing"); 1294 CX_TEST_ASSERT(msres->errors->next);
1337 UCX_TEST_ASSERT(!msres->errors->next->next, "wrong error list size"); 1295 CX_TEST_ASSERT(!msres->errors->next->next);
1338 1296
1339 // We know that we have 2 error lists, one with status code 409 and 1297 // We know that we have 2 error lists, one with status code 409 and
1340 // the other must have 409. However we don't enforce the order of the 1298 // the other must have 409. However we don't enforce the order of the
1341 // error lists, therefore check both variants 1299 // error lists, therefore check both variants
1342 if(msres->errors->status == 409) { 1300 if(msres->errors->status == 409) {
1343 UCX_TEST_ASSERT(msres->errors->next->status == 424, "wrong status code in second err elm"); 1301 CX_TEST_ASSERT(msres->errors->next->status == 424);
1344 UCX_TEST_ASSERT(msres->errors->begin, "missing 409 property"); 1302 CX_TEST_ASSERT(msres->errors->begin);
1345 UCX_TEST_ASSERT(msres->errors->next->begin, "missing 424 properties"); 1303 CX_TEST_ASSERT(msres->errors->next->begin);
1346 } else { 1304 } else {
1347 UCX_TEST_ASSERT(msres->errors->next->status == 409, "wrong status code in second err elm"); 1305 CX_TEST_ASSERT(msres->errors->next->status == 409);
1348 UCX_TEST_ASSERT(msres->errors->begin, "missing 424 properties"); 1306 CX_TEST_ASSERT(msres->errors->begin);
1349 UCX_TEST_ASSERT(msres->errors->next->begin, "missing 409 property"); 1307 CX_TEST_ASSERT(msres->errors->next->begin);
1350 } 1308 }
1351 1309
1352 UCX_TEST_END; 1310 }
1353 testutil_destroy_session(sn); 1311 testutil_destroy_session(sn);
1354 } 1312 }
1355 1313
1356 UCX_TEST(test_webdav_op_proppatch) { 1314 CX_TEST(test_webdav_op_proppatch) {
1357 Session *sn; 1315 Session *sn;
1358 Request *rq; 1316 Request *rq;
1359 WebdavOperation *op; 1317 WebdavOperation *op;
1360 1318
1361 Multistatus *ms; 1319 Multistatus *ms;
1369 p[i].lang = NULL; 1327 p[i].lang = NULL;
1370 p[i].value.node = NULL; 1328 p[i].value.node = NULL;
1371 p[1].vtype = 0; 1329 p[1].vtype = 0;
1372 } 1330 }
1373 1331
1374 UCX_TEST_BEGIN; 1332 CX_TEST_DO {
1375 1333
1376 // TEST_PROPPATCH2 should succeed 1334 // TEST_PROPPATCH2 should succeed
1377 reset_backends(); 1335 reset_backends();
1378 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2); 1336 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
1379 UCX_TEST_ASSERT(op, "failed to create proppatch operation"); 1337 CX_TEST_ASSERT(op);
1380 1338
1381 int ret = webdav_op_proppatch(op, "/", "/"); 1339 int ret = webdav_op_proppatch(op, "/", "/");
1382 UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed"); 1340 CX_TEST_ASSERT(ret == 0);
1383 UCX_TEST_ASSERT(backend1_proppatch_commit, "backend1 no commit"); 1341 CX_TEST_ASSERT(backend1_proppatch_commit);
1384 UCX_TEST_ASSERT(backend2_proppatch_commit, "backend2 no commit"); 1342 CX_TEST_ASSERT(backend2_proppatch_commit);
1385 UCX_TEST_ASSERT(backend1_proppatch_do_count == 1, "backend1 wrong count (1)"); 1343 CX_TEST_ASSERT(backend1_proppatch_do_count == 1);
1386 UCX_TEST_ASSERT(backend2_proppatch_do_count == 1, "backend1 wrong count (1)"); 1344 CX_TEST_ASSERT(backend2_proppatch_do_count == 1);
1387 UCX_TEST_ASSERT(backend1_proppatch_finish_count == 1, "backend1 wrong finish count (1)"); 1345 CX_TEST_ASSERT(backend1_proppatch_finish_count == 1);
1388 UCX_TEST_ASSERT(backend2_proppatch_finish_count == 1, "backend1 wrong finish count (1)"); 1346 CX_TEST_ASSERT(backend2_proppatch_finish_count == 1);
1389 1347
1390 // TEST_PROPPATCH3 should fail (commit == FALSE) 1348 // TEST_PROPPATCH3 should fail (commit == FALSE)
1391 reset_backends(); 1349 reset_backends();
1392 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH3); 1350 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH3);
1393 UCX_TEST_ASSERT(op, "failed to create proppatch operation 2"); 1351 CX_TEST_ASSERT(op);
1394 1352
1395 ret = webdav_op_proppatch(op, "/", "/"); 1353 ret = webdav_op_proppatch(op, "/", "/");
1396 UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed (2)"); 1354 CX_TEST_ASSERT(ret == 0);
1397 UCX_TEST_ASSERT(!backend1_proppatch_commit, "backend1 commit"); 1355 CX_TEST_ASSERT(!backend1_proppatch_commit);
1398 UCX_TEST_ASSERT(!backend2_proppatch_commit, "backend2 commit"); 1356 CX_TEST_ASSERT(!backend2_proppatch_commit);
1399 1357
1400 // TEST_PROPPATCH4 should abort 1358 // TEST_PROPPATCH4 should abort
1401 reset_backends(); 1359 reset_backends();
1402 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH4); 1360 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH4);
1403 UCX_TEST_ASSERT(op, "failed to create proppatch operation 3"); 1361 CX_TEST_ASSERT(op);
1404 1362
1405 ret = webdav_op_proppatch(op, "/", "/"); 1363 ret = webdav_op_proppatch(op, "/", "/");
1406 UCX_TEST_ASSERT(ret != 0, "webdav_op_proppatch should fail"); 1364 CX_TEST_ASSERT(ret != 0);
1407 UCX_TEST_ASSERT(backend1_proppatch_do_count == 1, "backend1 wrong count (2)"); 1365 CX_TEST_ASSERT(backend1_proppatch_do_count == 1);
1408 UCX_TEST_ASSERT(backend2_proppatch_do_count == 1, "backend1 wrong count (2)"); 1366 CX_TEST_ASSERT(backend2_proppatch_do_count == 1);
1409 UCX_TEST_ASSERT(backend1_proppatch_finish_count == 1, "backend1 wrong finish count (2)"); 1367 CX_TEST_ASSERT(backend1_proppatch_finish_count == 1);
1410 UCX_TEST_ASSERT(backend2_proppatch_finish_count == 0, "backend1 wrong finish count (2)"); 1368 CX_TEST_ASSERT(backend2_proppatch_finish_count == 0);
1411 1369
1412 UCX_TEST_END; 1370 }
1413 testutil_destroy_session(sn); 1371 testutil_destroy_session(sn);
1414 } 1372 }
1415 1373
1416 #define xstreq(a, b) (!strcmp((const char*)a, (const char*)b)) 1374 #define xstreq(a, b) (!strcmp((const char*)a, (const char*)b))
1417 1375
1418 UCX_TEST(test_webdav_proppatch) { 1376 CX_TEST(test_webdav_proppatch) {
1419 Session *sn; 1377 Session *sn;
1420 Request *rq; 1378 Request *rq;
1421 TestIOStream *st; 1379 TestIOStream *st;
1422 pblock *pb; 1380 pblock *pb;
1423 1381
1424 UCX_TEST_BEGIN; 1382 CX_TEST_DO {
1425 1383
1426 int ret; 1384 int ret;
1427 // Test 1 1385 // Test 1
1428 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/", TEST_PROPPATCH2); 1386 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/", TEST_PROPPATCH2);
1429 rq->davCollection = &backend1; 1387 rq->davCollection = &backend1;
1430 ret = webdav_proppatch(pb, sn, rq); 1388 ret = webdav_proppatch(pb, sn, rq);
1431 1389
1432 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_proppatch (1) failed"); 1390 CX_TEST_ASSERT(ret == REQ_PROCEED);
1433 1391
1434 xmlDoc *doc = xmlReadMemory( 1392 xmlDoc *doc = xmlReadMemory(
1435 st->buf->space, st->buf->size, NULL, NULL, 0); 1393 st->buf->space, st->buf->size, NULL, NULL, 0);
1436 UCX_TEST_ASSERT(doc, "proppatch1: response is not valid xml"); 1394 CX_TEST_ASSERT(doc);
1437 1395
1438 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); 1396 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
1439 1397
1440 xmlNode *root = xmlDocGetRootElement(doc); 1398 xmlNode *root = xmlDocGetRootElement(doc);
1441 UCX_TEST_ASSERT(root, "proppatch1: no root"); 1399 CX_TEST_ASSERT(root);
1442 1400
1443 xmlNode *nodeC = NULL; 1401 xmlNode *nodeC = NULL;
1444 xmlNode *node = root->children; 1402 xmlNode *node = root->children;
1445 int depth = 1; 1403 int depth = 1;
1446 while(node) { 1404 while(node) {
1473 node = node->children; 1431 node = node->children;
1474 depth++; 1432 depth++;
1475 } 1433 }
1476 } 1434 }
1477 1435
1478 UCX_TEST_ASSERT(nodeC, "prop c not in response"); 1436 CX_TEST_ASSERT(nodeC);
1479 UCX_TEST_ASSERT(!nodeC->children, "properties must not have a value"); 1437 CX_TEST_ASSERT(!nodeC->children);
1480 1438
1481 testutil_destroy_session(sn); 1439 testutil_destroy_session(sn);
1482 xmlFreeDoc(doc); 1440 xmlFreeDoc(doc);
1483 testutil_iostream_destroy(st); 1441 testutil_iostream_destroy(st);
1484 1442
1485 1443
1486 UCX_TEST_END; 1444 }
1487 } 1445 }
1488 1446
1489 1447
1490 /* ------------------------------------------------------------------------- 1448 /* -------------------------------------------------------------------------
1491 * 1449 *
1577 delete_finish_count++; 1535 delete_finish_count++;
1578 return 0; 1536 return 0;
1579 } 1537 }
1580 1538
1581 1539
1582 UCX_TEST(test_webdav_vfs_op_do) { 1540 CX_TEST(test_webdav_vfs_op_do) {
1583 Session *sn; 1541 Session *sn;
1584 Request *rq; 1542 Request *rq;
1585 TestIOStream *st; 1543 TestIOStream *st;
1586 pblock *pb; 1544 pblock *pb;
1587 1545
1617 dav2.next = &dav3; 1575 dav2.next = &dav3;
1618 dav3.next = &dav4; 1576 dav3.next = &dav4;
1619 1577
1620 rq->davCollection = &dav1; 1578 rq->davCollection = &dav1;
1621 1579
1622 UCX_TEST_BEGIN; 1580 CX_TEST_DO {
1623 1581
1624 WebdavVFSOperation *op1 = webdav_vfs_op(sn, rq, &dav1, FALSE); 1582 WebdavVFSOperation *op1 = webdav_vfs_op(sn, rq, &dav1, FALSE);
1625 1583
1626 int ret = webdav_vfs_op_do(op1, WEBDAV_VFS_MKDIR); 1584 int ret = webdav_vfs_op_do(op1, WEBDAV_VFS_MKDIR);
1627 1585
1628 UCX_TEST_ASSERT(!ret, "webdav_vfs_op_do failed"); 1586 CX_TEST_ASSERT(!ret);
1629 UCX_TEST_ASSERT(mkcol_count == 3, "wrong mkcol_count"); 1587 CX_TEST_ASSERT(mkcol_count == 3);
1630 UCX_TEST_ASSERT(mkcol_finish_count == 3, "wrong mkcol_finish_count"); 1588 CX_TEST_ASSERT(mkcol_finish_count == 3);
1631 UCX_TEST_ASSERT(mkcol_err == 0, "mkcol_err"); 1589 CX_TEST_ASSERT(mkcol_err == 0);
1632 1590
1633 // test without VFS, but set *created to TRUE to skip VFS usage 1591 // test without VFS, but set *created to TRUE to skip VFS usage
1634 rq->vfs = NULL; 1592 rq->vfs = NULL;
1635 set_created = 1; 1593 set_created = 1;
1636 1594
1637 WebdavVFSOperation *op2 = webdav_vfs_op(sn, rq, &dav1, FALSE); 1595 WebdavVFSOperation *op2 = webdav_vfs_op(sn, rq, &dav1, FALSE);
1638 ret = webdav_vfs_op_do(op2, WEBDAV_VFS_MKDIR); 1596 ret = webdav_vfs_op_do(op2, WEBDAV_VFS_MKDIR);
1639 1597
1640 UCX_TEST_ASSERT(!ret, "op2 failed"); 1598 CX_TEST_ASSERT(!ret);
1641 1599
1642 // test 3: abort after first backend 1600 // test 3: abort after first backend
1643 mkcol_count = 0; 1601 mkcol_count = 0;
1644 mkcol_finish_count = 0; 1602 mkcol_finish_count = 0;
1645 dav1.opt_mkcol = test_webdav_mkcol_fail; 1603 dav1.opt_mkcol = test_webdav_mkcol_fail;
1646 1604
1647 WebdavVFSOperation *op3 = webdav_vfs_op(sn, rq, &dav1, FALSE); 1605 WebdavVFSOperation *op3 = webdav_vfs_op(sn, rq, &dav1, FALSE);
1648 ret = webdav_vfs_op_do(op3, WEBDAV_VFS_MKDIR); 1606 ret = webdav_vfs_op_do(op3, WEBDAV_VFS_MKDIR);
1649 1607
1650 UCX_TEST_ASSERT(ret, "op3 should fail"); 1608 CX_TEST_ASSERT(ret);
1651 UCX_TEST_ASSERT(mkcol_count == 1, "op3: wrong mkcol_count"); 1609 CX_TEST_ASSERT(mkcol_count == 1);
1652 UCX_TEST_ASSERT(mkcol_finish_count == 1, "op3: wrong mkcol_finish_count"); 1610 CX_TEST_ASSERT(mkcol_finish_count == 1);
1653 1611
1654 // test DELETE to make sure, delete callbacks will be used 1612 // test DELETE to make sure, delete callbacks will be used
1655 pblock_replace("path", "/deltest", rq->vars); 1613 pblock_replace("path", "/deltest", rq->vars);
1656 rq->vfs = testvfs; 1614 rq->vfs = testvfs;
1657 WebdavVFSOperation *op_del = webdav_vfs_op(sn, rq, &dav1, FALSE); 1615 WebdavVFSOperation *op_del = webdav_vfs_op(sn, rq, &dav1, FALSE);
1658 vfs_open(op_del->vfs, "/deltest", O_CREAT); 1616 vfs_open(op_del->vfs, "/deltest", O_CREAT);
1659 ret = webdav_vfs_op_do(op_del, WEBDAV_VFS_DELETE); 1617 ret = webdav_vfs_op_do(op_del, WEBDAV_VFS_DELETE);
1660 1618
1661 UCX_TEST_ASSERT(!ret, "op_del failed"); 1619 CX_TEST_ASSERT(!ret);
1662 UCX_TEST_ASSERT(delete_count == 1, "op_del: wrong delete_count"); 1620 CX_TEST_ASSERT(delete_count == 1);
1663 UCX_TEST_ASSERT(delete_finish_count == 1, "op_del: wrong delete_finish_count"); 1621 CX_TEST_ASSERT(delete_finish_count == 1);
1664 1622
1665 1623
1666 UCX_TEST_END; 1624 }
1667 } 1625 }
1668 1626
1669 UCX_TEST(test_webdav_delete){ 1627 CX_TEST(test_webdav_delete){
1670 Session *sn; 1628 Session *sn;
1671 Request *rq; 1629 Request *rq;
1672 TestIOStream *st; 1630 TestIOStream *st;
1673 pblock *pb; 1631 pblock *pb;
1674 1632
1681 dav1.opt_delete_finish = test_backend_webdav_delete_finish; 1639 dav1.opt_delete_finish = test_backend_webdav_delete_finish;
1682 delete_count = 0; 1640 delete_count = 0;
1683 delete_finish_count = 0; 1641 delete_finish_count = 0;
1684 rq->davCollection = &dav1; 1642 rq->davCollection = &dav1;
1685 1643
1686 UCX_TEST_BEGIN; 1644 CX_TEST_DO {
1687 1645
1688 // prepare 1646 // prepare
1689 VFSContext *vfs = vfs_request_context(sn, rq); 1647 VFSContext *vfs = vfs_request_context(sn, rq);
1690 int err; 1648 int err;
1691 err = vfs_mkdir(vfs, "/dir1"); 1649 err = vfs_mkdir(vfs, "/dir1");
1692 UCX_TEST_ASSERT(err == 0, "mkdir dir1 failed"); 1650 CX_TEST_ASSERT(err == 0);
1693 err = vfs_mkdir(vfs, "/dir2"); 1651 err = vfs_mkdir(vfs, "/dir2");
1694 UCX_TEST_ASSERT(err == 0, "mkdir dir2 failed"); 1652 CX_TEST_ASSERT(err == 0);
1695 err = vfs_mkdir(vfs, "/dir2/dir3"); 1653 err = vfs_mkdir(vfs, "/dir2/dir3");
1696 UCX_TEST_ASSERT(err == 0, "mkdir dir3 failed"); 1654 CX_TEST_ASSERT(err == 0);
1697 err = vfs_mkdir(vfs, "/dir2/dir4"); 1655 err = vfs_mkdir(vfs, "/dir2/dir4");
1698 UCX_TEST_ASSERT(err == 0, "mkdir dir4 failed"); 1656 CX_TEST_ASSERT(err == 0);
1699 err = vfs_mkdir(vfs, "/dir2/dir4/dir5"); 1657 err = vfs_mkdir(vfs, "/dir2/dir4/dir5");
1700 UCX_TEST_ASSERT(err == 0, "mkdir dir5 failed"); 1658 CX_TEST_ASSERT(err == 0);
1701 1659
1702 SYS_FILE f0 = vfs_open(vfs, "/file0", O_CREAT); 1660 SYS_FILE f0 = vfs_open(vfs, "/file0", O_CREAT);
1703 UCX_TEST_ASSERT(f0, "f0 create failed"); 1661 CX_TEST_ASSERT(f0);
1704 // no f1 1662 // no f1
1705 SYS_FILE f2 = vfs_open(vfs, "/dir2/file2", O_CREAT); 1663 SYS_FILE f2 = vfs_open(vfs, "/dir2/file2", O_CREAT);
1706 UCX_TEST_ASSERT(f2, "f2 create failed"); 1664 CX_TEST_ASSERT(f2);
1707 SYS_FILE f3 = vfs_open(vfs, "/dir2/dir3/file3", O_CREAT); 1665 SYS_FILE f3 = vfs_open(vfs, "/dir2/dir3/file3", O_CREAT);
1708 UCX_TEST_ASSERT(f3, "f3 create failed"); 1666 CX_TEST_ASSERT(f3);
1709 SYS_FILE f4 = vfs_open(vfs, "/dir2/dir4/file4", O_CREAT); 1667 SYS_FILE f4 = vfs_open(vfs, "/dir2/dir4/file4", O_CREAT);
1710 UCX_TEST_ASSERT(f4, "f4 create failed"); 1668 CX_TEST_ASSERT(f4);
1711 SYS_FILE f5 = vfs_open(vfs, "/dir2/dir4/dir5/file5", O_CREAT); 1669 SYS_FILE f5 = vfs_open(vfs, "/dir2/dir4/dir5/file5", O_CREAT);
1712 UCX_TEST_ASSERT(f5, "f5 create failed"); 1670 CX_TEST_ASSERT(f5);
1713 1671
1714 // delete single file 1672 // delete single file
1715 pblock_replace("path", "/file0", rq->vars); 1673 pblock_replace("path", "/file0", rq->vars);
1716 err = webdav_delete(NULL, sn, rq); 1674 err = webdav_delete(NULL, sn, rq);
1717 UCX_TEST_ASSERT(err == 0, "DELETE /file0 failed"); 1675 CX_TEST_ASSERT(err == 0);
1718 UCX_TEST_ASSERT(delete_count == 1, "del1: wrong delete count"); 1676 CX_TEST_ASSERT(delete_count == 1);
1719 1677
1720 delete_count = 0; 1678 delete_count = 0;
1721 pblock_replace("path", "/dir1", rq->vars); 1679 pblock_replace("path", "/dir1", rq->vars);
1722 err = webdav_delete(NULL, sn, rq); 1680 err = webdav_delete(NULL, sn, rq);
1723 UCX_TEST_ASSERT(err == 0, "DELETE /dir1 failed"); 1681 CX_TEST_ASSERT(err == 0);
1724 UCX_TEST_ASSERT(delete_count == 1, "del1: wrong delete count"); 1682 CX_TEST_ASSERT(delete_count == 1);
1725 1683
1726 delete_count = 0; 1684 delete_count = 0;
1727 pblock_replace("path", "/dir2", rq->vars); 1685 pblock_replace("path", "/dir2", rq->vars);
1728 err = webdav_delete(NULL, sn, rq); 1686 err = webdav_delete(NULL, sn, rq);
1729 UCX_TEST_ASSERT(err == 0, "DELETE /dir2 failed"); 1687 CX_TEST_ASSERT(err == 0);
1730 UCX_TEST_ASSERT(delete_count == 8, "del2: wrong delete count"); 1688 CX_TEST_ASSERT(delete_count == 8);
1731 1689
1732 UCX_TEST_END; 1690 }
1733 } 1691 }
1734 1692
1735 UCX_TEST(test_webdav_put) { 1693 CX_TEST(test_webdav_put) {
1736 Session *sn; 1694 Session *sn;
1737 Request *rq; 1695 Request *rq;
1738 TestIOStream *st; 1696 TestIOStream *st;
1739 pblock *pb; 1697 pblock *pb;
1740 1698
1741 const char *content_const = "Hello World"; 1699 const char *content_const = "Hello World";
1742 1700
1743 init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", "/", content_const); 1701 init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", "/", content_const);
1744 rq->vfs = testvfs_create(sn); 1702 rq->vfs = testvfs_create(sn);
1745 1703
1746 UCX_TEST_BEGIN; 1704 CX_TEST_DO {
1747 1705
1748 int err; 1706 int err;
1749 1707
1750 pblock_replace("path", "/file0", rq->vars); 1708 pblock_replace("path", "/file0", rq->vars);
1751 err = webdav_put(NULL, sn, rq); 1709 err = webdav_put(NULL, sn, rq);
1752 1710
1753 UCX_TEST_ASSERT(err == REQ_PROCEED, "put failed"); 1711 CX_TEST_ASSERT(err == REQ_PROCEED);
1754 1712
1755 VFSContext *vfs = vfs_request_context(sn, rq); 1713 VFSContext *vfs = vfs_request_context(sn, rq);
1756 SYS_FILE f0 = vfs_open(vfs, "/file0", 0); 1714 SYS_FILE f0 = vfs_open(vfs, "/file0", 0);
1757 UCX_TEST_ASSERT(f0, "cannot open file0"); 1715 CX_TEST_ASSERT(f0);
1758 1716
1759 char buf[1024]; 1717 char buf[1024];
1760 int r = system_fread(f0, buf, 1024); 1718 int r = system_fread(f0, buf, 1024);
1761 1719
1762 UCX_TEST_ASSERT(r == strlen(content_const), "wrong file size"); 1720 CX_TEST_ASSERT(r == strlen(content_const));
1763 UCX_TEST_ASSERT(!memcmp(content_const, buf, r), "wrong file content"); 1721 CX_TEST_ASSERT(!memcmp(content_const, buf, r));
1764 1722
1765 testutil_destroy_session(sn); 1723 testutil_destroy_session(sn);
1766 testutil_iostream_destroy(st); 1724 testutil_iostream_destroy(st);
1767 1725
1768 UCX_TEST_END; 1726 }
1769 } 1727 }

mercurial