libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

test_plist.c (4544B)


      1 /*
      2      This file is part of libextractor.
      3      Copyright (C) 2026 Vidyut Samanta and Christian Grothoff
      4 
      5      libextractor is free software; you can redistribute it and/or modify
      6      it under the terms of the GNU General Public License as published
      7      by the Free Software Foundation; either version 3, or (at your
      8      option) any later version.
      9 
     10      libextractor is distributed in the hope that it will be useful, but
     11      WITHOUT ANY WARRANTY; without even the implied warranty of
     12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13      General Public License for more details.
     14 
     15      You should have received a copy of the GNU General Public License
     16      along with libextractor; see the file COPYING.  If not, write to the
     17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18      Boston, MA 02110-1301, USA.
     19 */
     20 /**
     21  * @file plugins/test_plist.c
     22  * @brief testcase for the plist plugin
     23  * @author Christian Grothoff
     24  *
     25  * Both test files hold the same dictionary, written once in each of
     26  * the two representations, so the two solution sets differ only where
     27  * the representations genuinely do: the binary form has a version and
     28  * an object count, the XML form does not.
     29  *
     30  * The values worth watching are the copyright (non-ASCII, and thus
     31  * UTF-16BE in the binary file) and the backup date, which only comes
     32  * out right if the 2001 epoch and the big-endian IEEE double were both
     33  * handled.
     34  */
     35 #include "platform.h"
     36 #include "test_lib.h"
     37 
     38 
     39 /**
     40  * Expected string item.
     41  */
     42 #define STR(t, s) { t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, \
     43                     strlen (s) + 1, 0, 0, NULL }
     44 
     45 
     46 /**
     47  * Main function for the plist testcase.
     48  *
     49  * @param argc number of arguments (ignored)
     50  * @param argv arguments (ignored)
     51  * @return 0 on success
     52  */
     53 int
     54 main (int argc, char *argv[])
     55 {
     56   struct SolutionData plist_binary_sol[] = {
     57     STR (EXTRACTOR_METATYPE_MIMETYPE, "application/x-plist"),
     58     STR (EXTRACTOR_METATYPE_FORMAT, "Binary property list"),
     59     STR (EXTRACTOR_METATYPE_FORMAT_VERSION, "00"),
     60     STR (EXTRACTOR_METATYPE_ENTRY_COUNT, "32"),
     61     STR (EXTRACTOR_METATYPE_AUTHORING_OS, "23A344"),
     62     STR (EXTRACTOR_METATYPE_FILENAME, "ExtractorTest"),
     63     STR (EXTRACTOR_METATYPE_APPLICATION_ID,
     64          "org.gnu.libextractor.testbundle"),
     65     STR (EXTRACTOR_METATYPE_PACKAGE_NAME, "ExtractorTest"),
     66     STR (EXTRACTOR_METATYPE_RESOURCE_TYPE, "APPL"),
     67     STR (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "1.19.0"),
     68     STR (EXTRACTOR_METATYPE_PACKAGE_VERSION, "4211"),
     69     STR (EXTRACTOR_METATYPE_TARGET_PLATFORM, "iphoneos"),
     70     STR (EXTRACTOR_METATYPE_TOOLCHAIN, "1520"),
     71     STR (EXTRACTOR_METATYPE_DEVICE_MODEL, "Test iPhone"),
     72     STR (EXTRACTOR_METATYPE_DEVICE_MODEL, "iPhone14,5"),
     73     STR (EXTRACTOR_METATYPE_UNKNOWN, "ExtractorTestInteger: 42"),
     74     STR (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2024-03-14T15:09:26Z"),
     75     STR (EXTRACTOR_METATYPE_MINIMUM_OS_VERSION, "14.0"),
     76     STR (EXTRACTOR_METATYPE_COPYRIGHT, "Copyright © 2026 Grüße"),
     77     STR (EXTRACTOR_METATYPE_SERIAL, "F2LXK0GTQ1GH"),
     78     { 0, 0, NULL, NULL, 0, -1, 0, NULL }
     79   };
     80   struct SolutionData plist_xml_sol[] = {
     81     STR (EXTRACTOR_METATYPE_MIMETYPE, "application/x-plist"),
     82     STR (EXTRACTOR_METATYPE_FORMAT, "XML property list"),
     83     STR (EXTRACTOR_METATYPE_AUTHORING_OS, "23A344"),
     84     STR (EXTRACTOR_METATYPE_FILENAME, "ExtractorTest"),
     85     STR (EXTRACTOR_METATYPE_APPLICATION_ID,
     86          "org.gnu.libextractor.testbundle"),
     87     STR (EXTRACTOR_METATYPE_PACKAGE_NAME, "ExtractorTest"),
     88     STR (EXTRACTOR_METATYPE_RESOURCE_TYPE, "APPL"),
     89     STR (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "1.19.0"),
     90     STR (EXTRACTOR_METATYPE_PACKAGE_VERSION, "4211"),
     91     STR (EXTRACTOR_METATYPE_TARGET_PLATFORM, "iphoneos"),
     92     STR (EXTRACTOR_METATYPE_TOOLCHAIN, "1520"),
     93     STR (EXTRACTOR_METATYPE_DEVICE_MODEL, "Test iPhone"),
     94     STR (EXTRACTOR_METATYPE_DEVICE_MODEL, "iPhone14,5"),
     95     STR (EXTRACTOR_METATYPE_UNKNOWN, "ExtractorTestInteger: 42"),
     96     STR (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2024-03-14T15:09:26Z"),
     97     STR (EXTRACTOR_METATYPE_MINIMUM_OS_VERSION, "14.0"),
     98     STR (EXTRACTOR_METATYPE_COPYRIGHT, "Copyright © 2026 Grüße"),
     99     STR (EXTRACTOR_METATYPE_SERIAL, "F2LXK0GTQ1GH"),
    100     { 0, 0, NULL, NULL, 0, -1, 0, NULL }
    101   };
    102   struct ProblemSet ps[] = {
    103     { "testdata/plist_binary.plist",
    104       plist_binary_sol },
    105     { "testdata/plist_xml.plist",
    106       plist_xml_sol },
    107     { NULL, NULL }
    108   };
    109 
    110   (void) argc;
    111   (void) argv;
    112   return ET_main ("plist", ps);
    113 }
    114 
    115 
    116 /* end of test_plist.c */