1 | /* $Id: tstRTZip.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT Testcase - RTZip, kind of.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include <iprt/zip.h>
|
---|
32 |
|
---|
33 | #include <iprt/env.h>
|
---|
34 | #include <iprt/errcore.h>
|
---|
35 | #include <iprt/initterm.h>
|
---|
36 | #include <iprt/file.h>
|
---|
37 | #include <iprt/mem.h>
|
---|
38 | #include <iprt/message.h>
|
---|
39 | #include <iprt/param.h>
|
---|
40 | #include <iprt/string.h>
|
---|
41 | #include <iprt/test.h>
|
---|
42 |
|
---|
43 |
|
---|
44 | static void testFile(const char *pszFilename)
|
---|
45 | {
|
---|
46 | size_t cbSrcActually = 0;
|
---|
47 | void *pvSrc;
|
---|
48 | size_t cbSrc;
|
---|
49 | int rc = RTFileReadAll(pszFilename, &pvSrc, &cbSrc);
|
---|
50 | RTTESTI_CHECK_RC_OK_RETV(rc);
|
---|
51 |
|
---|
52 | size_t cbDstActually = 0;
|
---|
53 | size_t cbDst = RT_MAX(cbSrc * 8, _1M);
|
---|
54 | void *pvDst = RTMemAllocZ(cbDst);
|
---|
55 |
|
---|
56 | rc = RTZipBlockDecompress(RTZIPTYPE_ZLIB, 0, pvSrc, cbSrc, &cbSrcActually, pvDst, cbDst, &cbDstActually);
|
---|
57 | RTTestIPrintf(RTTESTLVL_ALWAYS, "cbSrc=%zu cbSrcActually=%zu cbDst=%zu cbDstActually=%zu rc=%Rrc\n",
|
---|
58 | cbSrc, cbSrcActually, cbDst, cbDstActually, rc);
|
---|
59 | RTTESTI_CHECK_RC_OK(rc);
|
---|
60 |
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | int main(int argc, char **argv)
|
---|
65 | {
|
---|
66 | RTTEST hTest;
|
---|
67 | int rc = RTTestInitAndCreate("tstRTZip", &hTest);
|
---|
68 | if (rc)
|
---|
69 | return rc;
|
---|
70 | RTTestBanner(hTest);
|
---|
71 |
|
---|
72 | if (argc > 1)
|
---|
73 | {
|
---|
74 | for (int i = 1; i < argc; i++)
|
---|
75 | testFile(argv[i]);
|
---|
76 | }
|
---|
77 | else
|
---|
78 | {
|
---|
79 | /** @todo testcase */
|
---|
80 | }
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * Summary.
|
---|
84 | */
|
---|
85 | return RTTestSummaryAndDestroy(hTest);
|
---|
86 | }
|
---|
87 |
|
---|