security/nss/cmd/tests/baddbdir.c

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include <stdio.h>
     6 #include <stdlib.h>
     8 #include "nss.h"
     9 #include "secerr.h"
    11 /*
    12  * Regression test for bug 495097.
    13  *
    14  * NSS_InitReadWrite("sql:<dbdir>") should fail with SEC_ERROR_BAD_DATABASE
    15  * if the directory <dbdir> doesn't exist.
    16  */
    18 int main()
    19 {
    20     SECStatus status;
    21     int error;
    23     status = NSS_InitReadWrite("sql:/no/such/db/dir");
    24     if (status == SECSuccess) {
    25         fprintf(stderr, "NSS_InitReadWrite succeeded unexpectedly\n");
    26         exit(1);
    27     }
    28     error = PORT_GetError();
    29     if (error != SEC_ERROR_BAD_DATABASE) {
    30         fprintf(stderr, "NSS_InitReadWrite failed with the wrong error code: "
    31                 "%d\n", error);
    32         exit(1);
    33     }
    34     printf("PASS\n");
    35     return 0;
    36 }

mercurial