michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* A regression test for bug 794316 */ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "prio.h" michael@0: michael@0: static PRIOMethods dummyMethods; michael@0: michael@0: int main() michael@0: { michael@0: PRDescIdentity topId, middleId, bottomId; michael@0: PRFileDesc *top, *middle, *bottom; michael@0: PRFileDesc *fd; michael@0: michael@0: topId = PR_GetUniqueIdentity("top"); michael@0: middleId = PR_GetUniqueIdentity("middle"); michael@0: bottomId = PR_GetUniqueIdentity("bottom"); michael@0: michael@0: top = PR_CreateIOLayerStub(topId, &dummyMethods); michael@0: middle = PR_CreateIOLayerStub(middleId, &dummyMethods); michael@0: bottom = PR_CreateIOLayerStub(bottomId, &dummyMethods); michael@0: michael@0: fd = bottom; michael@0: PR_PushIOLayer(fd, PR_TOP_IO_LAYER, middle); michael@0: PR_PushIOLayer(fd, PR_TOP_IO_LAYER, top); michael@0: michael@0: top = fd; michael@0: middle = top->lower; michael@0: bottom = middle->lower; michael@0: michael@0: /* Verify that the higher pointers are correct. */ michael@0: if (middle->higher != top) { michael@0: fprintf(stderr, "middle->higher is wrong\n"); michael@0: fprintf(stderr, "FAILED\n"); michael@0: exit(1); michael@0: } michael@0: if (bottom->higher != middle) { michael@0: fprintf(stderr, "bottom->higher is wrong\n"); michael@0: fprintf(stderr, "FAILED\n"); michael@0: exit(1); michael@0: } michael@0: michael@0: top = PR_PopIOLayer(fd, topId); michael@0: top->dtor(top); michael@0: michael@0: middle = fd; michael@0: bottom = middle->lower; michael@0: michael@0: /* Verify that the higher pointer is correct. */ michael@0: if (bottom->higher != middle) { michael@0: fprintf(stderr, "bottom->higher is wrong\n"); michael@0: fprintf(stderr, "FAILED\n"); michael@0: exit(1); michael@0: } michael@0: michael@0: middle = PR_PopIOLayer(fd, middleId); michael@0: middle->dtor(middle); michael@0: if (fd->identity != bottomId) { michael@0: fprintf(stderr, "The bottom layer has the wrong identity\n"); michael@0: fprintf(stderr, "FAILED\n"); michael@0: exit(1); michael@0: } michael@0: fd->dtor(fd); michael@0: michael@0: printf("PASS\n"); michael@0: return 0; michael@0: }