1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/cmd/tests/baddbdir.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include <stdio.h> 1.9 +#include <stdlib.h> 1.10 + 1.11 +#include "nss.h" 1.12 +#include "secerr.h" 1.13 + 1.14 +/* 1.15 + * Regression test for bug 495097. 1.16 + * 1.17 + * NSS_InitReadWrite("sql:<dbdir>") should fail with SEC_ERROR_BAD_DATABASE 1.18 + * if the directory <dbdir> doesn't exist. 1.19 + */ 1.20 + 1.21 +int main() 1.22 +{ 1.23 + SECStatus status; 1.24 + int error; 1.25 + 1.26 + status = NSS_InitReadWrite("sql:/no/such/db/dir"); 1.27 + if (status == SECSuccess) { 1.28 + fprintf(stderr, "NSS_InitReadWrite succeeded unexpectedly\n"); 1.29 + exit(1); 1.30 + } 1.31 + error = PORT_GetError(); 1.32 + if (error != SEC_ERROR_BAD_DATABASE) { 1.33 + fprintf(stderr, "NSS_InitReadWrite failed with the wrong error code: " 1.34 + "%d\n", error); 1.35 + exit(1); 1.36 + } 1.37 + printf("PASS\n"); 1.38 + return 0; 1.39 +}