baddbdir.c (949B)
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/. */ 4 5 #include <stdio.h> 6 #include <stdlib.h> 7 8 #include "nss.h" 9 #include "secerr.h" 10 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 */ 17 18 int 19 main() 20 { 21 SECStatus status; 22 int error; 23 24 status = NSS_InitReadWrite("sql:/no/such/db/dir"); 25 if (status == SECSuccess) { 26 fprintf(stderr, "NSS_InitReadWrite succeeded unexpectedly\n"); 27 exit(1); 28 } 29 error = PORT_GetError(); 30 if (error != SEC_ERROR_BAD_DATABASE) { 31 fprintf(stderr, "NSS_InitReadWrite failed with the wrong error code: " 32 "%d\n", 33 error); 34 exit(1); 35 } 36 printf("PASS\n"); 37 return 0; 38 }