/
FSUtilsTests.swift
33 lines (26 loc) · 1.08 KB
/
FSUtilsTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* 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/. */
import Foundation
import XCTest
@testable import Shared
class FSUtilsTests: XCTestCase {
func testListOpenFileDescriptors() {
let tempA = "\(NSTemporaryDirectory())A.tmp"
let tempB = "\(NSTemporaryDirectory())B.tmp"
let tempC = "\(NSTemporaryDirectory())C.tmp"
var openDescriptors = FSUtils.openFileDescriptors()
let prevCount = openDescriptors.keys.count
// Open up some file descriptors
let fdA = open(tempA, O_RDWR | O_CREAT)
let fdB = open(tempB, O_RDWR | O_CREAT)
let fdC = open(tempC, O_RDWR | O_CREAT)
openDescriptors = FSUtils.openFileDescriptors()
XCTAssertEqual(openDescriptors.keys.count, prevCount + 3)
close(fdA)
close(fdB)
close(fdC)
openDescriptors = FSUtils.openFileDescriptors()
XCTAssertEqual(openDescriptors.keys.count, prevCount)
}
}