Home | History | Annotate | Download | only in platform_PrinterPpds
      1 Tests naming convention
      2 -----------------------
      3 Names of tests (suffixes of control.* files) are build from 2 or 3 words
      4 separated by an underscore character. The first one is '100' or 'all', what
      5 defines the set of PPD files to test: '100' means 100 chosen (most often used)
      6 PPD files (stored in the archive ppds_100) while 'all' means all available PPD
      7 files (stored in the archive ppds_all). The second word of the name is either
      8 'test' or 'dump'. The third and optional word is 'debug'. All these three words
      9 influence testing procedure used by the autotest, their meanings are described
     10 in next paragraphs.
     11 
     12 Overall testing procedure
     13 -------------------------
     14 The purpose of this autotest is to verify that given subset of PPD files work
     15 in ChromeOS. Each PPD file is tested with the following procedure:
     16 1. A printer driver is added to CUPS server.
     17 2. Test documents are printed on the configured printer.
     18 3. Raw output from the CUPS server is intercepted by, so called, FakePrinter.
     19 4. CUPS logs are parsed to make sure that no errors occured.
     20 5. Obtained outputs are verified (see below) - test only.
     21 6. A printing pipeline used by CUPS is rerun in shell (see below) - debug only.
     22 7. All obtained outputs & logs are saved on the device (see below) - dump only.
     23 8. The printer driver is removed from CUPS server.
     24 This procedure is repeated for every PPD file. The number of PPD files may be
     25 large (3K+ files). To decrease amount of time needed by the autotest, several
     26 PPD files are tested simultaneously in parallel threads. Autotest always run
     27 the procedure for all given PPD files and print a summary report at the end.
     28 If at least one of PPD files fails, whole autotest is finished with failure
     29 (but always all PPD files are processed).
     30 
     31 Output verification ('test')
     32 ----------------------------
     33 Intercepted output is verified by comparision with the previous results
     34 obtained for the same PPD. We cannot store outputs directly, because their
     35 total size may have hundreds of megabytes. Instead of that short digest is
     36 calculated for each obtained document and it is used for comparison.
     37 A function for digests calculation is in the 'helpers.py' file. Not all
     38 outputs can be tested this way because for some PPD files produced contents
     39 differ between runs. List of PPD files for which we cannot calculate
     40 constant digest is saved in the file digests_blacklist.txt. Files with
     41 expected digests for every test document are stored in the directory "digests".
     42 If a digests for given pair (test document, PPD file) is missing, the test
     43 checks only check if the output is not empty (or not too short).
     44 
     45 Rerun printing pipeline ('debug')
     46 ---------------------------------
     47 Every PPD file defines printing pipeline used by CUPS, consisting of external
     48 binaries (so called filters). To make sure that every part of the printing
     49 pipeline works correctly, it can be run outside CUPS in Linux shell. In tests
     50 with 'debug' suffix in their names, whole pipeline is rerun outside CUPS. In
     51 this mode every document is processed twice: the first time by CUPS and the
     52 second time by extracted pipeline run as bash script. Additionally, each
     53 pipeline's step is verified by checking its return code (it is supposed to be
     54 equal 0) and the final output is compared with the output returned by CUPS
     55 server. If the test is also defined as 'dump', each intermediate content is
     56 saved to the directory given in path_outputs parameter.
     57 This mode requires more disk space on tested device (~2GB in /tmp) and takes
     58 more execution time (~2 times more). All information needed to reconstruct
     59 a pipeline used by CUPS can are extracted from CUPS logs after the job is
     60 completed. To do that, CUPS configuration must be modified: the LogLevel
     61 option in /etc/cups/cupsd.conf must be set to "debug". This modification is
     62 done when the autotest is initialized; the original setting is restored in
     63 the cleaup stage. 
     64 
     65 
     66 Save outputs and logs ('dump')
     67 ------------------------------
     68 All obtained outputs and logs are saved on the device in the directory
     69 /tmp/PrinterPpds_outputs/. Results obtained from PPD files with the same prefix
     70 are grouped together and stored in single archive to limit usage of disk space.
     71 
     72 Test parameters
     73 ---------------
     74 path_docs - path to directory with test documents (PDF files)
     75 path_ppds - path to directory with PPD files, if not set then all available PPD
     76             files are downloaded and tested
     77 path_digests - path to directory with files containing digests for
     78             verification, if not set then outputs are not verified
     79 path_outputs - if set, then all outputs are dumped there (given directory is
     80             deleted if already exists); also all digests files are recalculated
     81             and saved in the same directory
     82 debug_mode - True or False, if True then for every test the printing pipeline
     83             is extracted from CUPS logs and executed again outside CUPS
     84 
     85 Generating new digests
     86 ----------------------
     87 The following procedure can be used to update digests:
     88 1. Run the test defined in control.all_dump:
     89         test_that <device IP>  platform_PrinterPpds.all_dump
     90 2. Download generated files with digests to your workstation
     91         rsync root@<device IP>:/tmp/PrinterPpds_outputs/*.digests <local dir>
     92 3. Replace the files from the "digests" directory and commit changes
     93 
     94 Updating the archive with PPD files
     95 -----------------------------------
     96 Currently, all tests are based on PPD files stored in local directories. The
     97 autotest can download all PPD files by itself, but we do not use this option
     98 to limit the number of possible points of failures during testing. PPD files
     99 are stored in the archive 'ppds_all.tar.xz'. To replace the archive with the
    100 current list of supported PPD files, one can use the script 
    101 'download_ppds_make_archive.py'.
    102 
    103 Others
    104 ------
    105 * How to get comma-separated list of all used ghostscript devices?
    106   1. Go to the directory generated by all_dump_debug
    107   2. Unpack all tar.xz archives (not on the device)
    108         for d in *.pdf;
    109         do
    110             cd $d;
    111             for f in *.tar.xz; do tar xf $f; done ;
    112             cd ..;
    113         done
    114   3. Run the following
    115         grep -o sDEVICE=[^\ ]*\  ./*.pdf/*.err[12345] | cut -d \= -f 2 | sort | uniq | tr -d ' ' | tr '\n' ','
    116   4. Add to the list uniprint (it is not caught by the command above)
    117 * How to get a list of all used cups filters?
    118   1. Go to the directory generated by all_dump_debug
    119   2. Unpack all tar.xz archives (not on the device)
    120         for d in *.pdf;
    121         do
    122             cd $d;
    123             for f in *.tar.xz; do tar xf $f; done ;
    124             cd ..;
    125         done
    126   3. Run the following
    127         grep -o '(exec -a "Fake[^"]*" [^ ]* ' ./*.pdf/*.sh | cut -d \  -f 4 | sort | uniq
    128