Back to index

lightning-sunbird  0.9+nobinonly
vercheck.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039  * File: vercheck.c
00040  *
00041  * Description:
00042  * This test tests the PR_VersionCheck() function.  The
00043  * compatible_version and incompatible_version arrays
00044  * need to be updated for each patch or release.
00045  *
00046  * Tested areas: library version compatibility check.
00047  */
00048 
00049 #include "prinit.h"
00050 
00051 #include <stdio.h>
00052 #include <stdlib.h>
00053 
00054 /*
00055  * This release (4.6.8) is backward compatible with the
00056  * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6, 4.6.1, 4.6.2,
00057  * 4.6.3, 4.6.4, 4.6.5, 4.6.6 and 4.6.7 releases.  It, of course,
00058  * is compatible with itself.
00059  */
00060 static char *compatible_version[] = {
00061     "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3",
00062     "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1",
00063     "4.5", "4.5.1", "4.6", "4.6.1", "4.6.2", "4.6.3",
00064     "4.6.4", "4.6.5", "4.6.6", "4.6.7", PR_VERSION
00065 };
00066 
00067 /*
00068  * This release is not backward compatible with the old
00069  * NSPR 2.1 and 3.x releases.
00070  *
00071  * Any release is incompatible with future releases and
00072  * patches.
00073  */
00074 static char *incompatible_version[] = {
00075     "2.1 19980529",
00076     "3.0", "3.0.1",
00077     "3.1", "3.1.1", "3.1.2", "3.1.3",
00078     "3.5", "3.5.1",
00079     "4.6.99",
00080     "4.7", "4.7.1",
00081     "10.0", "11.1", "12.14.20"
00082 };
00083 
00084 int main()
00085 {
00086     int idx;
00087     int num_compatible = sizeof(compatible_version) / sizeof(char *);
00088     int num_incompatible = sizeof(incompatible_version) / sizeof(char *);
00089 
00090     printf("NSPR release %s:\n", PR_VERSION);
00091     for (idx = 0; idx < num_compatible; idx++) {
00092         if (PR_VersionCheck(compatible_version[idx]) == PR_FALSE) {
00093             fprintf(stderr, "Should be compatible with version %s\n",
00094                     compatible_version[idx]);
00095             exit(1);
00096         }
00097         printf("Compatible with version %s\n", compatible_version[idx]);
00098     }
00099 
00100     for (idx = 0; idx < num_incompatible; idx++) {
00101         if (PR_VersionCheck(incompatible_version[idx]) == PR_TRUE) {
00102             fprintf(stderr, "Should be incompatible with version %s\n",
00103                     incompatible_version[idx]);
00104             exit(1);
00105         }
00106         printf("Incompatible with version %s\n", incompatible_version[idx]);
00107     }
00108 
00109     printf("PASS\n");
00110     return 0;
00111 }