Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * File: vercheck.c |
michael@0 | 8 | * |
michael@0 | 9 | * Description: |
michael@0 | 10 | * This test tests the PR_VersionCheck() function. The |
michael@0 | 11 | * compatible_version and incompatible_version arrays |
michael@0 | 12 | * need to be updated for each patch or release. |
michael@0 | 13 | * |
michael@0 | 14 | * Tested areas: library version compatibility check. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #include "prinit.h" |
michael@0 | 18 | |
michael@0 | 19 | #include <stdio.h> |
michael@0 | 20 | #include <stdlib.h> |
michael@0 | 21 | |
michael@0 | 22 | /* |
michael@0 | 23 | * This release (4.10.6) is backward compatible with the |
michael@0 | 24 | * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x, |
michael@0 | 25 | * 4.8.x, 4.9.x, 4.10, 4.10.1, 4.10.2, 4.10.3, 4.10.4, and |
michael@0 | 26 | * 4.10.5 releases. |
michael@0 | 27 | * It, of course, is compatible with itself. |
michael@0 | 28 | */ |
michael@0 | 29 | static char *compatible_version[] = { |
michael@0 | 30 | "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3", |
michael@0 | 31 | "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1", |
michael@0 | 32 | "4.5", "4.5.1", |
michael@0 | 33 | "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5", |
michael@0 | 34 | "4.6.6", "4.6.7", "4.6.8", |
michael@0 | 35 | "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5", |
michael@0 | 36 | "4.7.6", |
michael@0 | 37 | "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5", |
michael@0 | 38 | "4.8.6", "4.8.7", "4.8.8", "4.8.9", |
michael@0 | 39 | "4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5", |
michael@0 | 40 | "4.9.6", |
michael@0 | 41 | "4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4", |
michael@0 | 42 | "4.10.5", |
michael@0 | 43 | PR_VERSION |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | /* |
michael@0 | 47 | * This release is not backward compatible with the old |
michael@0 | 48 | * NSPR 2.1 and 3.x releases. |
michael@0 | 49 | * |
michael@0 | 50 | * Any release is incompatible with future releases and |
michael@0 | 51 | * patches. |
michael@0 | 52 | */ |
michael@0 | 53 | static char *incompatible_version[] = { |
michael@0 | 54 | "2.1 19980529", |
michael@0 | 55 | "3.0", "3.0.1", |
michael@0 | 56 | "3.1", "3.1.1", "3.1.2", "3.1.3", |
michael@0 | 57 | "3.5", "3.5.1", |
michael@0 | 58 | "4.10.7", |
michael@0 | 59 | "4.11", "4.11.1", |
michael@0 | 60 | "10.0", "11.1", "12.14.20" |
michael@0 | 61 | }; |
michael@0 | 62 | |
michael@0 | 63 | int main(int argc, char **argv) |
michael@0 | 64 | { |
michael@0 | 65 | int idx; |
michael@0 | 66 | int num_compatible = sizeof(compatible_version) / sizeof(char *); |
michael@0 | 67 | int num_incompatible = sizeof(incompatible_version) / sizeof(char *); |
michael@0 | 68 | |
michael@0 | 69 | printf("NSPR release %s:\n", PR_VERSION); |
michael@0 | 70 | for (idx = 0; idx < num_compatible; idx++) { |
michael@0 | 71 | if (PR_VersionCheck(compatible_version[idx]) == PR_FALSE) { |
michael@0 | 72 | fprintf(stderr, "Should be compatible with version %s\n", |
michael@0 | 73 | compatible_version[idx]); |
michael@0 | 74 | exit(1); |
michael@0 | 75 | } |
michael@0 | 76 | printf("Compatible with version %s\n", compatible_version[idx]); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | for (idx = 0; idx < num_incompatible; idx++) { |
michael@0 | 80 | if (PR_VersionCheck(incompatible_version[idx]) == PR_TRUE) { |
michael@0 | 81 | fprintf(stderr, "Should be incompatible with version %s\n", |
michael@0 | 82 | incompatible_version[idx]); |
michael@0 | 83 | exit(1); |
michael@0 | 84 | } |
michael@0 | 85 | printf("Incompatible with version %s\n", incompatible_version[idx]); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | printf("PASS\n"); |
michael@0 | 89 | return 0; |
michael@0 | 90 | } |