バージョンごとのドキュメント一覧

33.3. 各種の比較用ファイル #

<title>Variant Comparison Files</title>

Since some of the tests inherently produce environment-dependent results, we have provided ways to specify alternate <quote>expected</quote> result files. Each regression test can have several comparison files showing possible results on different platforms. There are two independent mechanisms for determining which comparison file is used for each test. 試験の中には必然的に環境に依存した結果となるものがありますので、expected結果ファイルの代替を指定する方法を用意しています。 各リグレッションテストは、異なるプラットフォームで出力される可能性がある、複数の比較用ファイルを持つことができます。 各試験に対してどの比較用ファイルを使用するかを決定する方法には、独立した2つの機構があります。

The first mechanism allows comparison files to be selected for specific platforms. There is a mapping file, <filename>src/test/regress/resultmap</filename>, that defines which comparison file to use for each platform. To eliminate bogus test <quote>failures</quote> for a particular platform, you first choose or make a variant result file, and then add a line to the <filename>resultmap</filename> file. 1つ目のメカニズムにより、特定のプラットフォームのための比較用ファイルを選ぶことができます。 関連付けを行うsrc/test/regress/resultmapというファイルがあり、どの比較用ファイルがどのプラットフォームで使用されるのかを定義します。 特定のプラットフォームにおいて試験の失敗の誤検知を防ぐためには、まず結果ファイルを選ぶ、あるいは結果ファイルを作成してから、resultmapファイルに1行加えてください。

Each line in the mapping file is of the form マッピングファイルの各行の書式は下記の通りです。

testname:output:platformpattern=comparisonfilename

The test name is just the name of the particular regression test module. The output value indicates which output file to check. For the standard regression tests, this is always <literal>out</literal>. The value corresponds to the file extension of the output file. The platform pattern is a pattern in the style of the Unix tool <command>expr</command> (that is, a regular expression with an implicit <literal>^</literal> anchor at the start). It is matched against the platform name as printed by <command>config.guess</command>. The comparison file name is the base name of the substitute result comparison file. testnameは特定のリグレッションテストのモジュール名です。 outputの値は、どの出力ファイルを検査するのかを示します。 標準のリグレッションテストでは、これは常にoutです。 この値は出力ファイルの拡張子に対応します。 platformpatternとは、expr Unixツールスタイル(最初に暗黙的な^がある正規表現)のパターンです。 これはconfig.guessによって出力されるプラットフォーム名と比較されます。 comparisonfilenameは置き換える結果比較ファイルの(ディレクトリ部分を除いた)名前です。

For example: some systems lack a working <literal>strtof</literal> function, for which our workaround causes rounding errors in the <filename>float4</filename> regression test. Therefore, we provide a variant comparison file, <filename>float4-misrounded-input.out</filename>, which includes the results to be expected on these systems. To silence the bogus <quote>failure</quote> message on <systemitem>Cygwin</systemitem> platforms, <filename>resultmap</filename> includes: 以下に例を示します。 システムの中には、動作するstrtof関数がないものがあり、そのため私たちの回避策がfloat4リグレッションテストでの丸め誤差の原因となります。 そのため、float4-misrounded-input.outという異なる比較ファイルを用意し、そこにこういったシステムでの期待される値を記述します。 Cygwinプラットフォームにおいて偽の失敗メッセージ出力を行わせないようにするために、resultmapに以下を含めます。

float4:out:.*-.*-cygwin.*=float4-misrounded-input.out

which will trigger on any machine where the output of <command>config.guess</command> matches <literal>.*-.*-cygwin.*</literal>. Other lines in <filename>resultmap</filename> select the variant comparison file for other platforms where it's appropriate. これは、config.guessの出力が.*-.*-cygwin.*に一致するすべてのマシンに対して適用されます。 resultmapのその他の行は、他のプラットフォーム向けの適切な比較ファイルを選択します。

The second selection mechanism for variant comparison files is much more automatic: it simply uses the <quote>best match</quote> among several supplied comparison files. The regression test driver script considers both the standard comparison file for a test, <literal><replaceable>testname</replaceable>.out</literal>, and variant files named <literal><replaceable>testname</replaceable>_<replaceable>digit</replaceable>.out</literal> (where the <replaceable>digit</replaceable> is any single digit <literal>0</literal>-<literal>9</literal>). If any such file is an exact match, the test is considered to pass; otherwise, the one that generates the shortest diff is used to create the failure report. (If <filename>resultmap</filename> includes an entry for the particular test, then the base <replaceable>testname</replaceable> is the substitute name given in <filename>resultmap</filename>.) 2つ目の比較用ファイルの選択の仕組みはかなり自動化されています。 これは単純に、提供されている各種比較用ファイルの中からもっとも一致するものを使用します。 リグレッションテストのドライバスクリプトは、試験において、標準の比較用ファイルtestname.outtestname_digit.out(ここでdigit0-9のいずれかからなる1つの数字です)という名前の別のファイルの両方を考慮します。 もしこの中のいずれかのファイルが正確に一致した場合、試験が成功したものとみなします。 さもなくば、生成されたdiffの結果がもっとも小さかった結果ファイルを選択して、失敗報告を生成します。 (resultmapに特定の試験用の項目が含まれていると、resultmap内の名前が元となるtestnameに置き換えられます。)

For example, for the <literal>char</literal> test, the comparison file <filename>char.out</filename> contains results that are expected in the <literal>C</literal> and <literal>POSIX</literal> locales, while the file <filename>char_1.out</filename> contains results sorted as they appear in many other locales. 例えば、charの試験では、比較用ファイルchar.outにはCロケールとPOSIXロケールで想定される結果が含まれています。 一方、char_1.outファイルには、他の多くのロケールで現れる結果がソートされて含まれています。

The best-match mechanism was devised to cope with locale-dependent results, but it can be used in any situation where the test results cannot be predicted easily from the platform name alone. A limitation of this mechanism is that the test driver cannot tell which variant is actually <quote>correct</quote> for the current environment; it will just pick the variant that seems to work best. Therefore it is safest to use this mechanism only for variant results that you are willing to consider equally valid in all contexts. この最善一致の仕組みは、ロケールに依存した結果に対応できるように考え出されました。 しかし、この仕組みはプラットフォームの名前だけでは簡単に予測できる試験結果とならないような、任意の状況で使用することができます。 この仕組みの制約は、現在の環境でどの種類の比較ファイルが本当に正しいのかが試験ドライバでは分からないという点です。 単にもっともうまく動いていそうなものを選択しているだけだからです。 したがって、すべての文脈で平等に有効とみなすことができるような種類の結果においてのみ利用するのが、もっとも安全です。