1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/tests/vercheck.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * File: vercheck.c 1.11 + * 1.12 + * Description: 1.13 + * This test tests the PR_VersionCheck() function. The 1.14 + * compatible_version and incompatible_version arrays 1.15 + * need to be updated for each patch or release. 1.16 + * 1.17 + * Tested areas: library version compatibility check. 1.18 + */ 1.19 + 1.20 +#include "prinit.h" 1.21 + 1.22 +#include <stdio.h> 1.23 +#include <stdlib.h> 1.24 + 1.25 +/* 1.26 + * This release (4.10.6) is backward compatible with the 1.27 + * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x, 1.28 + * 4.8.x, 4.9.x, 4.10, 4.10.1, 4.10.2, 4.10.3, 4.10.4, and 1.29 + * 4.10.5 releases. 1.30 + * It, of course, is compatible with itself. 1.31 + */ 1.32 +static char *compatible_version[] = { 1.33 + "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3", 1.34 + "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1", 1.35 + "4.5", "4.5.1", 1.36 + "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5", 1.37 + "4.6.6", "4.6.7", "4.6.8", 1.38 + "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5", 1.39 + "4.7.6", 1.40 + "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5", 1.41 + "4.8.6", "4.8.7", "4.8.8", "4.8.9", 1.42 + "4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5", 1.43 + "4.9.6", 1.44 + "4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4", 1.45 + "4.10.5", 1.46 + PR_VERSION 1.47 +}; 1.48 + 1.49 +/* 1.50 + * This release is not backward compatible with the old 1.51 + * NSPR 2.1 and 3.x releases. 1.52 + * 1.53 + * Any release is incompatible with future releases and 1.54 + * patches. 1.55 + */ 1.56 +static char *incompatible_version[] = { 1.57 + "2.1 19980529", 1.58 + "3.0", "3.0.1", 1.59 + "3.1", "3.1.1", "3.1.2", "3.1.3", 1.60 + "3.5", "3.5.1", 1.61 + "4.10.7", 1.62 + "4.11", "4.11.1", 1.63 + "10.0", "11.1", "12.14.20" 1.64 +}; 1.65 + 1.66 +int main(int argc, char **argv) 1.67 +{ 1.68 + int idx; 1.69 + int num_compatible = sizeof(compatible_version) / sizeof(char *); 1.70 + int num_incompatible = sizeof(incompatible_version) / sizeof(char *); 1.71 + 1.72 + printf("NSPR release %s:\n", PR_VERSION); 1.73 + for (idx = 0; idx < num_compatible; idx++) { 1.74 + if (PR_VersionCheck(compatible_version[idx]) == PR_FALSE) { 1.75 + fprintf(stderr, "Should be compatible with version %s\n", 1.76 + compatible_version[idx]); 1.77 + exit(1); 1.78 + } 1.79 + printf("Compatible with version %s\n", compatible_version[idx]); 1.80 + } 1.81 + 1.82 + for (idx = 0; idx < num_incompatible; idx++) { 1.83 + if (PR_VersionCheck(incompatible_version[idx]) == PR_TRUE) { 1.84 + fprintf(stderr, "Should be incompatible with version %s\n", 1.85 + incompatible_version[idx]); 1.86 + exit(1); 1.87 + } 1.88 + printf("Incompatible with version %s\n", incompatible_version[idx]); 1.89 + } 1.90 + 1.91 + printf("PASS\n"); 1.92 + return 0; 1.93 +}