1231200Smm/*- 2231200Smm * Copyright (c) 2011 Tim Kientzle 3231200Smm * All rights reserved. 4231200Smm * 5231200Smm * Redistribution and use in source and binary forms, with or without 6231200Smm * modification, are permitted provided that the following conditions 7231200Smm * are met: 8231200Smm * 1. Redistributions of source code must retain the above copyright 9231200Smm * notice, this list of conditions and the following disclaimer. 10231200Smm * 2. Redistributions in binary form must reproduce the above copyright 11231200Smm * notice, this list of conditions and the following disclaimer in the 12231200Smm * documentation and/or other materials provided with the distribution. 13231200Smm * 14231200Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15231200Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16231200Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17231200Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18231200Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19231200Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20231200Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21231200Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22231200Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23231200Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24231200Smm */ 25231200Smm 26231200Smm#include "test.h" 27231200Smm__FBSDID("$FreeBSD$"); 28231200Smm 29231200Smm#define DATA "random garbage for testing purposes" 30231200Smm 31231200Smmstatic const char data[sizeof(DATA)] = DATA; 32231200Smm 33231200Smmstatic void 34231200Smmtest(int skip_explicitely) 35231200Smm{ 36231200Smm struct archive* a = archive_read_new(); 37231200Smm struct archive_entry* e; 38231200Smm 39231200Smm assertEqualInt(ARCHIVE_OK, archive_read_support_format_raw(a)); 40231200Smm assertEqualInt(0, archive_errno(a)); 41231200Smm assertEqualString(NULL, archive_error_string(a)); 42231200Smm 43232153Smm assertEqualInt(ARCHIVE_OK, archive_read_open_memory(a, 44232153Smm (void *)(uintptr_t) data, sizeof(data))); 45231200Smm assertEqualString(NULL, archive_error_string(a)); 46231200Smm 47231200Smm assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &e)); 48231200Smm assertEqualInt(0, archive_errno(a)); 49231200Smm assertEqualString(NULL, archive_error_string(a)); 50231200Smm 51231200Smm if (skip_explicitely) 52231200Smm assertEqualInt(ARCHIVE_OK, archive_read_data_skip(a)); 53231200Smm 54231200Smm assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &e)); 55231200Smm assertEqualInt(0, archive_errno(a)); 56231200Smm assertEqualString(NULL, archive_error_string(a)); 57231200Smm 58231200Smm archive_read_free(a); 59231200Smm} 60231200Smm 61231200SmmDEFINE_TEST(test_archive_read_next_header_raw) 62231200Smm{ 63231200Smm test(1); 64231200Smm test(0); 65231200Smm} 66