< Previous PageNext Page > Hide TOC

Testing and Deploying Drivers

You’ve created your driver and thoroughly debugged it. Now you’re ready to test it and prepare it for installation on your customers’s computers. This chapter outlines testing strategies and describes how to use the Mac OS X Package Maker application to create an installable package.

In this section:

Testing Strategies
Packaging Drivers for Installation


Testing Strategies

Now that you’ve debugged your driver and you know it’s working perfectly, you should test it on as many differently configured computers and as many different operating system releases as you plan to support (or expect your customers to have).

Basic Quality Control

The first step in testing your driver is to perform a basic quality-control pass. Ideally, many of these checks should be part of your day-to-day development methodology:

When you are ready to deploy the driver, build it using the Development build style (in Project Builder) to get the full range of debugging symbols. Save a copy of the driver in case you or another developer might ever need a symboled version of it. Then, to get the final product, strip the symbols from the driver using the strip tool. Note that you use the Development build style instead of the Deployment build style for the final build of the driver. The Deployment style introduces additional optimizations that do little to enhance driver performance and yet make it harder to match up symbols in the stripped and non-stripped versions of the binary.

Configuration Testing

Configuration testing aims to test the operation of your driver within a range of factors that stress-test its performance under various conditions, possibly revealing a latent bug. These factors include the following:

Power-Management Testing

Many drivers implement some form of power management, responding to or initiating requests to sleep, power down, or power up. You should ensure this capability is thoroughly tested. One way to test power management is power cycling. Put a system with your driver installed on it asleep, then wake it up. Repeat this sequence many times (the more the better) to see if a bug in your power-management code surfaces.

If your driver is for a device that is “hot-swappable” (FireWire, USB, and PC Card), test the code in your driver that is responsible for handling device connection and (especially) device removal. You want to ensure that the driver stack is gracefully torn down when a device is disconnected. As with power-management testing, disconnect and reconnect the device many times to see if the sheer repetition of the event reveals a bug.

Other Testing Strategies and Goals

Here are a few more suggestions to help you test your driver:

If possible, you can let your Apple developer technical support contact know you’re about to ship a driver. If you supply Apple with the CFBundleIdentifier and version that uniquely identifies your driver, Apple will know who to contact if a problem report appears that seems to point to your driver.

Packaging Drivers for Installation

Before you send your driver out the door, you should package it so it’s easy for your customers to install. Mac OS X provides the Package Maker application (available in /Developer/Applications and a command-line version available in /Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker) to create your package. The Package Maker application guides you through the creation of a package and creates the required files from information you enter in its editing windows, making the process almost automatic. The command-line tool requires you to supply the necessary files you’ve created yourself. For more detailed information on how to use Package Maker to create a package, see the Package Maker Help menu. For more information on using the command-line version, type ./PackageMaker -help from the /Developer/Applications/PackageMaker.app/Contents/MacOS directory.

The following sections provide an overview of the components of a Package Maker package, describe what comprises a valid package, and outline how your package gets installed. If you use another package-making tool to create your package, make sure the resulting package contains all the required elements discussed in these sections.

Note: This chapter describes the Package Maker application available in Mac OS X version 10.2 and above. To create packages that can also be installed on earlier versions of Mac OS X, you should use an earlier version of Package Maker.

Package Contents

A Package Maker package is an Info.plist-based NSBundle object that contains the information the Installer requires to install software on a Mac OS X system. Package contents are separated into required global resources and optional localizable resources. Listing 8-1 shows the format of a package named MyPackage.

Listing 8-1  PackageMaker format for MyPackage

MyPackage.pkg
    Contents
        Info.plist
        Archive.pax.gz
        Archive.bom
        Resources
            /* Optional, localizable package-description information */
            Description.plist
 
            /* Optional, localizable documents */
            License document
            ReadMe document
            Welcome document
 
            /* Optional scripts */
            preinstall script
            postinstall script
            preupgrade script
            postupgrade script
            preflight script
            postflight script
 
            /* Optional check tools */
            InstallationCheck tool
            VolumeCheck tool
 
            /* Optional, localizable background image */
            background
 
            /* Optional language project folders. If present, these */
            /* folders contain localized versions of Description.plist, */
            /* License, ReadMe, Welcome, and background files. */
            English.lproj
            Japanese.lproj

Package Maker creates the package’s Info.plist file using the information you enter in the Info window. Information such as the default installation location and level of user authorization required allow you to customize the installation of your package’s contents.

Note: If your files must be installed in a non-user location, such as /System/Library/Extensions for KEXTs, you must create your package with admin or root authorization.

The Archive.bom and Archive.pax.gz files are required files Package Maker creates for you using information you enter in the Files window. The Archive.bom file is a bill-of-materials file that describes the contents of the package to the Installer. The Archive.pax.gz file is a compressed archive containing the contents of a package. (In earlier versions of Package Maker, these filenames incorporated the package name, as in MyPackage.bom and MyPackage.pax.gz.)

The Resources folder contains documents, scripts, and tools you provide for the Installer to use during installation. With the exception of the Description.plist file (which contains the information you enter in the Description window), Package Maker does not create these files for you. You have complete control over the contents of these files, but you do have to follow Package Maker’s naming conventions, or the Installer will not find and execute them.

You must name your localizable documents License.extension, ReadMe.extension, and Welcome.extension where extension is html, rtf, rtfd, txt, or no extension at all. In Mac OS X version 10.2, you can customize the background image the Installer displays when it opens the package. You must name your background picture file background.extension, where extension is jpg, tif, tiff, gif, pict, eps, or pdf.

The optional scripts must also follow Package Maker’s naming conventions. You can perform a wide range of tasks in these scripts but you should take care not to overburden them or the installation speed will suffer. For example, you could create folders in a preflight script, but it would be better to set up the necessary folders in the archive. As a general rule, you should try to create your package so that it provides everything your software needs, using the scripts sparingly to perform dynamic tasks during the install process. If you do include scripts to run during installation, be sure to make them executable.

If you need to examine a computer’s configuration prior to installation to determine, for example, if there is sufficient memory to run the Installer, or if some other software is present, you can provide an InstallationCheck tool. The Installer runs this tool (if it is present) when it first opens a package. As with the optional scripts, you must follow Package Maker’s naming convention and you must make the tool executable. In addition, the InstallationCheck tool must return an integer error code. The error code is used as a bitfield that encodes information about the installation status that the Installer can interpret. The Installer uses some of the bits as an index into files of error messages, either predefined by the Installer or custom. If you choose to define your own set of error messages, you create a localizable InstallationCheck.strings file and place it in your localized .lproj folder.

The Installer generally gives the user a choice of volumes on which to install your package. If you need to disable one or more volume choices, you can provide a VolumeCheck tool (you must name the tool VolumeCheck and make it executable). The Installer runs this tool (if it is present) before it displays the Target Select window. Like InstallationCheck, VolumeCheck returns an integer result code that is treated as a bitfield. The Installer uses some bits to identify several properties about the status of VolumeCheck and others as an index into either a predefined or a custom error message file named VolumeCheck.strings.

A metapackage is simply a package of prebuilt packages. If, for example, you offer a suite of drivers, you can create a metapackage to contain them all and allow your customers to install the ones they choose. To create a metapackage, select New Meta Package from Package Maker’s File menu.

A metapackage has the same components as a single package, with the addition of a list of subpackages (each of which must be a valid package). For specific differences in the Info.plist keys, see Package Maker’s Package Format Notes.

Package Validation and Installation

Package Maker provides a validation tool you can run on your package to flag potential problems (to run it, select Validate Package in the Tools menu). You can run the tool on packages built with any version of Package Maker. The tool checks for the presence of required files and that the scripts are executable. A valid package must contain

A valid metapackage must contain

When the Installer installs a single package, it performs the following steps:

  1. Run the InstallationCheck script (if present).

  2. Display the Welcome screen.

  3. Display the ReadMe screen.

  4. Display the License screen.

  5. Run the VolumeCheck script (if present) for each available volume.

  6. Display the volume selection screen.

  7. Wait for the user to select the target volume and click Install.

  8. Run the preflight script, if present.

  9. Run the preinstall script (or preupgrade script, if this is an upgrade), if present.

  10. Copy the files to the target drive (if this is an upgrade, some files may be copied to an intermediate directory first).

  11. Run the postinstall script (or postupgrade script, if this is an upgrade), if present.

  12. If this is an upgrade, copy the files in the intermediate directory to their final destination.

  13. Copy the receipt to the target drive’s Receipts folder.

  14. Run the postflight script, if present.

  15. Reboot or quit, depending on the package’s flags.

The Installer performs a similar set of steps when installing a metapackage:

  1. Run the InstallationCheck script, if present.

  2. Display the Welcome screen.

  3. Display the ReadMe screen.

  4. Display the License screen.

  5. Run the VolumeCheck script (if present) for each available volume.

  6. Display the volume selection screen.

  7. Wait for the user to select the target volume and click Install.

  8. Perform the following steps for each subpackage

    1. Run preflight script, if present.

    2. Run the preinstall script (or preupgrade script, if this is an upgrade), if present.

    3. Copy the files to the target drive (if this is an upgrade, some files may be copied to an intermediate directory first).

    4. Run the postinstall script (or postupgrade script, if this is an upgrade), if present.

    5. If this is an upgrade, copy the files in the intermediate directory to their final destination.

    6. Run the postflight script, if present.

  9. Reboot or quit, depending on the metapackage’s flags.

If you’ve used another tool to create your package, you should examine the installed files carefully to make sure everything is where you want it to be.



< Previous PageNext Page > Hide TOC


© 2002, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-06)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.