Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* A regression test for bug 794316 */ |
michael@0 | 7 | |
michael@0 | 8 | #include <stdio.h> |
michael@0 | 9 | #include <stdlib.h> |
michael@0 | 10 | |
michael@0 | 11 | #include "prio.h" |
michael@0 | 12 | |
michael@0 | 13 | static PRIOMethods dummyMethods; |
michael@0 | 14 | |
michael@0 | 15 | int main() |
michael@0 | 16 | { |
michael@0 | 17 | PRDescIdentity topId, middleId, bottomId; |
michael@0 | 18 | PRFileDesc *top, *middle, *bottom; |
michael@0 | 19 | PRFileDesc *fd; |
michael@0 | 20 | |
michael@0 | 21 | topId = PR_GetUniqueIdentity("top"); |
michael@0 | 22 | middleId = PR_GetUniqueIdentity("middle"); |
michael@0 | 23 | bottomId = PR_GetUniqueIdentity("bottom"); |
michael@0 | 24 | |
michael@0 | 25 | top = PR_CreateIOLayerStub(topId, &dummyMethods); |
michael@0 | 26 | middle = PR_CreateIOLayerStub(middleId, &dummyMethods); |
michael@0 | 27 | bottom = PR_CreateIOLayerStub(bottomId, &dummyMethods); |
michael@0 | 28 | |
michael@0 | 29 | fd = bottom; |
michael@0 | 30 | PR_PushIOLayer(fd, PR_TOP_IO_LAYER, middle); |
michael@0 | 31 | PR_PushIOLayer(fd, PR_TOP_IO_LAYER, top); |
michael@0 | 32 | |
michael@0 | 33 | top = fd; |
michael@0 | 34 | middle = top->lower; |
michael@0 | 35 | bottom = middle->lower; |
michael@0 | 36 | |
michael@0 | 37 | /* Verify that the higher pointers are correct. */ |
michael@0 | 38 | if (middle->higher != top) { |
michael@0 | 39 | fprintf(stderr, "middle->higher is wrong\n"); |
michael@0 | 40 | fprintf(stderr, "FAILED\n"); |
michael@0 | 41 | exit(1); |
michael@0 | 42 | } |
michael@0 | 43 | if (bottom->higher != middle) { |
michael@0 | 44 | fprintf(stderr, "bottom->higher is wrong\n"); |
michael@0 | 45 | fprintf(stderr, "FAILED\n"); |
michael@0 | 46 | exit(1); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | top = PR_PopIOLayer(fd, topId); |
michael@0 | 50 | top->dtor(top); |
michael@0 | 51 | |
michael@0 | 52 | middle = fd; |
michael@0 | 53 | bottom = middle->lower; |
michael@0 | 54 | |
michael@0 | 55 | /* Verify that the higher pointer is correct. */ |
michael@0 | 56 | if (bottom->higher != middle) { |
michael@0 | 57 | fprintf(stderr, "bottom->higher is wrong\n"); |
michael@0 | 58 | fprintf(stderr, "FAILED\n"); |
michael@0 | 59 | exit(1); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | middle = PR_PopIOLayer(fd, middleId); |
michael@0 | 63 | middle->dtor(middle); |
michael@0 | 64 | if (fd->identity != bottomId) { |
michael@0 | 65 | fprintf(stderr, "The bottom layer has the wrong identity\n"); |
michael@0 | 66 | fprintf(stderr, "FAILED\n"); |
michael@0 | 67 | exit(1); |
michael@0 | 68 | } |
michael@0 | 69 | fd->dtor(fd); |
michael@0 | 70 | |
michael@0 | 71 | printf("PASS\n"); |
michael@0 | 72 | return 0; |
michael@0 | 73 | } |