Dia antes primera install
This commit is contained in:
33
node_modules/i2c-bus/integration-test/async-brute-force-leak-check.js
generated
vendored
Normal file
33
node_modules/i2c-bus/integration-test/async-brute-force-leak-check.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const leakTest = testRuns => {
|
||||
const tlbuf = Buffer.alloc(1000000);
|
||||
|
||||
i2c1.readI2cBlock(DS1621_ADDR, CMD_ACCESS_TL, 2, tlbuf, (err, bytesRead, buffer) => {
|
||||
assert(!err, 'can\'t read block data from tl');
|
||||
assert.strictEqual(bytesRead, 2, 'expected readI2cBlock to read 2 bytes');
|
||||
|
||||
if (testRuns % 1000 === 0) {
|
||||
console.log(testRuns);
|
||||
}
|
||||
|
||||
testRuns -= 1;
|
||||
if (testRuns === 0) {
|
||||
i2c1.closeSync();
|
||||
} else {
|
||||
leakTest(testRuns);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
assert(!err, 'can\'t open i2c bus');
|
||||
leakTest(1000000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user