libextractor

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

gen_plist_testdata.sh (1868B)


      1 #!/bin/sh
      2 # Regenerate the property list test data for src/plugins/test_plist.c.
      3 #
      4 # Needs nothing beyond python3 (Debian package "python3"); plistlib is
      5 # part of the standard library.  The output is deterministic: every
      6 # value, including the date, is hard-coded here and asserted on in
      7 # test_plist.c.
      8 #
      9 # The dictionary mixes the keys of an application bundle Info.plist
     10 # (CFBundle*, DT*) with those of an iOS backup Info.plist (DeviceName,
     11 # ProductType, SerialNumber, LastBackupDate) so that one small file
     12 # exercises both halves of the key table.  NSHumanReadableCopyright is
     13 # deliberately non-ASCII: in the binary form plistlib then has to store
     14 # it as UTF-16BE, which is the string decoder we most want covered.
     15 #
     16 # This file is part of libextractor; the generated data is CC0.
     17 set -e
     18 
     19 out="$(dirname "$0")/../src/plugins/testdata"
     20 
     21 python3 - "$out" <<'EOF'
     22 import datetime
     23 import os
     24 import plistlib
     25 import sys
     26 
     27 out = sys.argv[1]
     28 
     29 d = {
     30     'BuildMachineOSBuild': '23A344',
     31     'CFBundleExecutable': 'ExtractorTest',
     32     'CFBundleIdentifier': 'org.gnu.libextractor.testbundle',
     33     'CFBundleName': 'ExtractorTest',
     34     'CFBundlePackageType': 'APPL',
     35     'CFBundleShortVersionString': '1.19.0',
     36     'CFBundleVersion': '4211',
     37     'DTPlatformName': 'iphoneos',
     38     'DTXcode': '1520',
     39     'DeviceName': 'Test iPhone',
     40     'ExtractorTestInteger': 42,
     41     'LastBackupDate': datetime.datetime(2024, 3, 14, 15, 9, 26),
     42     'MinimumOSVersion': '14.0',
     43     'NSHumanReadableCopyright': 'Copyright © 2026 Grüße',
     44     'ProductType': 'iPhone14,5',
     45     'SerialNumber': 'F2LXK0GTQ1GH',
     46 }
     47 
     48 with open(os.path.join(out, 'plist_binary.plist'), 'wb') as f:
     49     plistlib.dump(d, f, fmt=plistlib.FMT_BINARY)
     50 with open(os.path.join(out, 'plist_xml.plist'), 'wb') as f:
     51     plistlib.dump(d, f, fmt=plistlib.FMT_XML)
     52 EOF
     53 
     54 ls -l "$out/plist_binary.plist" "$out/plist_xml.plist"