locktests.c revision 0b98289ef95e83fcd493ba6688e57aa8b4fb53f7
/* liblxcapi
*
* Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
* Copyright © 2012 Canonical Ltd.
*
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#define mycontainername "lxctest.sem"
#define TIMEOUT_SECS 3
static void test_two_locks(void)
{
struct lxc_lock *l;
int p[2];
char c;
if (pipe(p) < 0)
exit(1);
exit(1);
if (pid == 0) {
if (read(p[0], &c, 1) < 0) {
perror("read");
exit(1);
}
if (!l) {
exit(1);
}
if (lxclock(l, 0) < 0) {
exit(1);
}
exit(0);
}
if (!l) {
exit(1);
}
if (lxclock(l, 0) < 0) {
exit(1);
}
perror("write");
exit(1);
}
sleep(3);
if (WEXITSTATUS(status) == 0)
exit(1);
} else
return;
} else if (ret < 0) {
perror("waitpid");
exit(1);
}
close(p[1]);
close(p[0]);
lxcunlock(l);
lxc_putlock(l);
}
{
int ret;
if (!lock) {
exit(1);
}
if (ret) {
exit(1);
}
if (ret) {
exit(1);
}
if (!lock) {
exit(1);
}
// we don't create the file until the container is running, so this
// bit of the test needs to be changed
if (ret != 0) {
pathname);
exit(1);
}
}