security/nss/cmd/tests/baddbdir.c
author Jeff Walden <jwalden@mit.edu>
Tue, 19 Nov 2019 04:55:39 +0000
changeset 502538 b5c5ba07d3dbd0d07b66fa42a103f4df2c27d3a2
parent 295081 d19089f751447f6a1a1443c529111aab34945298
permissions -rw-r--r--
Bug 1596544 - intl_ValidateAndCanonicalizeUnicodeExtensionType should ignore the second |option| argument until it's needed to report an error. r=anba Differential Revision: https://phabricator.services.mozilla.com/D53145

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <stdio.h>
#include <stdlib.h>

#include "nss.h"
#include "secerr.h"

/*
 * Regression test for bug 495097.
 *
 * NSS_InitReadWrite("sql:<dbdir>") should fail with SEC_ERROR_BAD_DATABASE
 * if the directory <dbdir> doesn't exist.
 */

int
main()
{
    SECStatus status;
    int error;

    status = NSS_InitReadWrite("sql:/no/such/db/dir");
    if (status == SECSuccess) {
        fprintf(stderr, "NSS_InitReadWrite succeeded unexpectedly\n");
        exit(1);
    }
    error = PORT_GetError();
    if (error != SEC_ERROR_BAD_DATABASE) {
        fprintf(stderr, "NSS_InitReadWrite failed with the wrong error code: "
                        "%d\n",
                error);
        exit(1);
    }
    printf("PASS\n");
    return 0;
}